what is using a port
Find the program listening on a port (port 80 here), see what it is, and stop it if it should not be there.
Steps
-
sudo ss -tulpn | grep ':80 'what listens on port 80, with its program and PID (Linux)
-
sudo lsof -i :80the same with lsof, on Linux and macOS
-
sudo fuser -v 80/tcpanother way to ask, by port (Linux)
-
ps -fp PIDthe whole command line of that PID
-
systemctl status PIDthe service it belongs to, if it is one
-
sudo kill PIDstop it, once you know it is safe to
Notes
- Put your port in place of 80, and the number you found in place of PID.
- Only root can listen on ports under 1024, and
ssandlsofshow other users' programs only with sudo. - A service stopped with
killmay be started again by systemd: stop it withsudo systemctl stop NAME. - macOS:
sudo lsof -nP -iTCP:80 -sTCP:LISTEN.
Commands used
sslsoffusernetstat
Each has a page in lore: lore ss opens it.
Related recipes
- check a certificateSee a site's TLS certificate, when it expires and who issued it, or the same for a .pem file.
- copy files to and from a serverCopy a file or a whole folder between this machine and another one over ssh.
- download a whole folder from a websiteFetch every file under a web folder, without climbing to the folders above it.
- find this machine's ip addressThis machine's address on the local network, and the one the internet sees.