# blade create network occupy

网络本地端口占用

## 介绍

本地端口占用，验证端口已被占用的情况下，使用此端口的业务容错能力

## 参数

```
--port string             指定被占用的端口，（必填项）
--force                   强制占用此端口，会将已使用此端口的进程杀掉
--timeout string          设定运行时长，单位是秒，通用参数
```

## 案例

```
# 指定 8080 端口占用
blade c network occupy --port 8080 --force

# 命令执行前
netstat -tanp | grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      19562/java

# 命令执行后
netstat -tanp | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      20041/chaos_occupyn
```

## 实现原理

指定端口启动 server 实现

## 常见问题

Q: {"code":604,"success":false,"error":"Error: listen tcp :8080: bind: address already in use exit status 1"} A：指定的端口已被占用，可以添加 `--force` 参数，强制杀掉使用此端口的进程


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chaosblade-io.gitbook.io/chaosblade-help-zh-cn/blade-create-network-occupy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
