View port occupation and release port tutorial on Mac system

When developing on a Mac, you may encounter an error message that the port is occupied. At this time, you can use the "Terminal" application to use the command lsof -i tcp:port (port is replaced with the port number, such as 6379/8080) to view the port What program is occupied, and display PID, which is convenient for KILL (kill pid)

1. Check which program the port is occupied by
sudo lsof -i tcp:port
such as:

sudo lsof -i tcp:8080 Check whether port 8080 is occupied
. 2. See the PID of the process, you can kill the process.
sudo kill -9 PID
such as:

sudo kill -9 3210

Guess you like

Origin blog.51cto.com/15118280/2651033