Cover image

Free port in MAC

8/5/2017, 3:51:03 PM

Sometimes, when we are developing a server #program , the #port may be occupied because we abnormally shut down our program. Therefore, we should find the process which is occupying the port and close it then the program work in the same port could work well.

Here are the instructions to find and close the #process in #MAC

  1. find the port info
# lsof -i :PORT_NUMBER
# for example the process in port 5566
lsof -i :5566
# output
COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node    5955 ...
  1. kill the process in port 5566 via PID
#-9 means force kill
kill -9 5955

After kill the process, you could execute the other program working in the same port number now.

Reference: