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: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)
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).