# 如何解除端口占用？

![](https://3490195898-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnQxDcxCKODvYvTUWe3%2F-M1soWbilAV6z3JUKC_4%2F-M1sonYauhEkf2ciAR-A%2Fimage.png?alt=media\&token=99b56914-7046-4bdb-b356-f6e6137b101c)

这是我个人在开发过程中经常碰到的问题，在通过IDE调试的时候，用`webpack`起一个server后挂掉了，也不知道哪里可以找到对应端口的占用进程，于是乎每次匆匆忙忙的检索一番。

这里算是总结一下，非常简单：

#### 1.查看端口占用程序

```
lsof -i:[端口号]
```

如：

```
lsof -i:8080
```

#### 2.结束占用进程

```
kill -9 [pid]
```

如

```
kill -9 9635
```

哇，世界清净了。


---

# 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://mm.ricky.moe/blog/how-to-free-port.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.
