Skip to content
RIPE NCC member · Local Internet RegistryCall us on 020 3318 3449sales@hosting-telecom.uk

Which program is using a port, and how to free it

The “Address already in use” error: how to find out what is listening on a port, and how to stop the service or end the process properly.

Contents

If a service fails to start with the error “Address already in use”, the port is already taken by another program. First find out which one.

What is using the port

sudo ss -ltnp 'sport = :80'

The output shows the program name and its process number (pid). The option letters mean: l — listening ports, t — TCP (u — UDP), n — port numbers instead of names, p — processes. To see all ports in use at once, run sudo ss -ltnp.

You can get the same information with sudo lsof -i :80 or sudo fuser -v -n tcp 80, if they are installed. On FreeBSD, use sockstat -4 -l -p 80.

How to free the port

If a service is holding the port, stop it properly — that way it will not start again by itself:

sudo systemctl stop nginx
sudo systemctl disable nginx   # if you do not need the service after a reboot either

If it is a standalone or hung process, end it by its process number:

sudo kill 1524      # ask the process to exit
sudo kill -9 1524   # force it — if the process is still alive after a few seconds
Warning kill -9 does not give the program a chance to save its data. Never stop a database this way — stop it through its own service.

Didn’t find the answer? Ask our support team — we’ll help.

Choose which cookies we may use. You can change your mind at any time with the “Cookie settings” link at the bottom of every page.

Necessary

Always active

They keep the site secure and remember your cookie choice. They don’t identify you.

Google Analytics counts visits and shows which pages people find useful, so we can improve the site. Which cookies