> For the complete documentation index, see [llms.txt](https://mm.ricky.moe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mm.ricky.moe/blog/how-to-free-port.md).

# 如何解除端口占用？

![](/files/-M1sonYauhEkf2ciAR-A)

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

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

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

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

如：

```
lsof -i:8080
```

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

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

如

```
kill -9 9635
```

哇，世界清净了。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://mm.ricky.moe/blog/how-to-free-port.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
