Sometimes, there’s a program running on a port and you don’t know what it is. How do you find out? I find this happens when I start a webserver up to test something locally and then I forget about it. So, if I wanted to find out what was running on port 80:
1 2 3 4 5 |
sudo lsof -i :80 # checks port 80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ruby 64888 wg 6u IPv4 0x6ddd270 0t0 TCP *:gds_db (LISTEN) |
you can then
1 |
KILL -9 64888 |
to kill that particular process that is blocking your port.
This command shows a list of open files. The -i option checks for internet addresses with the colon symbol representing a port (instead of an actual IP address). Note, I’ve only used this on Mac OS X. I’m not sure if there’s an equivalent for *nix or if it’s available in some package.