View port occupancy and release port 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

The above is the tutorial on viewing port occupation and release port on Mac system brought to you by the editor. I hope it will be helpful to you. If you want to know more about Mac related content, please follow macz.com!

Guess you like

Origin blog.csdn.net/fox_lori/article/details/114533476