Method of Releasing Port Occupation in Linux

  • 2021-07-03 01:09:59
  • OfStack

In this example, assume that port 8080 is occupied.

1. Check to see if Port 8080 is occupied


netstat -anp | grep 8080
 Output: tcp    0   0 :::8080           :::*            LISTEN   3000/java   

It can be seen from the above that port 8080 has been opened.

2. View the processes using port 8080:

fuser -v -n tcp 8080

Output:

USER PID ACCESS COMMAND 8080/tcp:
zhu 1154 F.... java

3. Kill processes that use port 8080:

kill -s 9 1154(自己的进程号).

4. View all processes:

ps

Output:

PID TTY TIME CMD
2949 pts/1 00:00:00 bash
3037 pts/1 00:00:00 ps

This is to find that the 1154 process no longer exists

Summarize


Related articles: