Short answer

“Address already in use” means another program already listens on that port. Find it with sudo ss -tlnp 'sport = :80' (use your port): the users: column names the program and its PID. Without sudo, that column is empty. Stop the program through its service, for example sudo systemctl disable --now apache2, then start yours.

Tested on Ubuntu 26.04 and 24.04, two separate runs. On 24.04? One section differs, each step marked “On Ubuntu 24.04” right under it: The error: “bind() to 0.0.0.0:80 failed (98: Address already in use)”. Everything that differed

The error: “bind() to 0.0.0.0:80 failed (98: Address already in use)”

The test server already ran Apache, the most common case. Installing Nginx on it looks normal, and the end of the output gives no sign of a problem:

Server
$ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nginx[… 60 lines not shown …] No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host.
Output hidden (7 lines)

In the middle of that output, apt printed Failed to start NGINX in postinst script and then carried on, and the command still ended without an error. Nginx is installed but not running:

On Ubuntu 24.04

Ubuntu 24.04’s Nginx package checks the port before it tries, and prints Not attempting to start NGINX, port 80 is already in use. instead, also in the middle of the output. The result is the same: Nginx is not running, and the steps below are the same.

Server
$ systemctl is-active nginxfailed
Output hidden (1 line)
Server
$ sudo journalctl -u nginx --no-pager -n 20 | grep -m 2 "Address already in use"Nov 19 09:32:32 web-server nginx[3615]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)Nov 19 09:32:32 web-server nginx[3631]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Output hidden (2 lines)

Nginx tried both the IPv4 address (0.0.0.0:80) and the IPv6 one ([::]:80), and something already had both. It tries up to five times, half a second apart, which is why the same line repeats.

Find which process is using the port

ss is installed on every Ubuntu server (netstat is not). -t is TCP, -l listening sockets, -n numbers instead of names, -p the process. Run it without sudo first:

Server
$ ss -tlnp 'sport = :80'State         Recv-Q        Send-Q               Local Address:Port               Peer Address:Port       ProcessLISTEN        0             511                              *:80                            *:*
Output hidden (2 lines)

The port is taken (LISTEN), but the Process column is empty: a normal user may not see other users’ processes. With sudo:

Server
$ sudo ss -tlnp 'sport = :80'State           Recv-Q          Send-Q                   Local Address:Port                   Peer Address:Port         ProcessLISTEN          0               511                                  *:80                                *:*             users:(("apache2",pid=2586,fd=4),("apache2",pid=2585,fd=4),("apache2",pid=2569,fd=4))
Output hidden (2 lines)

apache2 holds it, with several PIDs: one main process and its workers share the same socket. Two other tools give the same answer in other shapes. lsof shows the user of each process:

Server
$ sudo lsof -nP -iTCP:80 -sTCP:LISTENCOMMAND  PID     USER FD   TYPE DEVICE SIZE/OFF NODE NAMEapache2 2569     root 4u  IPv6  17824      0t0  TCP *:80 (LISTEN)apache2 2585 www-data 4u  IPv6  17824      0t0  TCP *:80 (LISTEN)apache2 2586 www-data 4u  IPv6  17824      0t0  TCP *:80 (LISTEN)
Output hidden (4 lines)
Server
$ sudo fuser -v 80/tcp                     USER        PID ACCESS COMMAND80/tcp:              root       2569 F.... apache2                     www-data   2585 F.... apache2                     www-data   2586 F.... apache2
Output hidden (4 lines)

Before you stop anything, find out what it belongs to. A program started by systemd comes back if you only kill it:

Server
$ systemctl status apache2 --no-pager | head -n 3● apache2.service - The Apache HTTP Server     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)     Active: active (running) since Thu 2026-11-19 09:31:40 UTC; 1min 29s ago
Output hidden (3 lines)

Free the port, then start your program

disable --now stops Apache now and also keeps it from starting at the next boot, when it would take port 80 back before Nginx:

Server
$ sudo systemctl disable --now apache2Synchronizing state of apache2.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.Executing: /usr/lib/systemd/systemd-sysv-install disable apache2Removed '/etc/systemd/system/multi-user.target.wants/apache2.service'.
Output hidden (3 lines)
Server
$ sudo ss -tlnp 'sport = :80'State        Recv-Q        Send-Q               Local Address:Port               Peer Address:Port       Process
Output hidden (1 line)

Only the header line: nothing listens on port 80 now. Start Nginx and check who has the port:

Server
$ sudo systemctl start nginx
Server
$ systemctl is-active nginxactive
Output hidden (1 line)
Server
$ sudo ss -tlnp 'sport = :80'State           Recv-Q          Send-Q                   Local Address:Port                   Peer Address:Port         ProcessLISTEN          0               511                            0.0.0.0:80                          0.0.0.0:*             users:(("nginx",pid=4543,fd=5),("nginx",pid=4542,fd=5),("nginx",pid=4541,fd=5))LISTEN          0               511                               [::]:80                             [::]:*             users:(("nginx",pid=4543,fd=6),("nginx",pid=4542,fd=6),("nginx",pid=4541,fd=6))
Output hidden (3 lines)
Server
$ curl -sI http://localhost | grep -i "^server"Server: nginx/1.28.3 (Ubuntu)
Output hidden (1 line)

Nginx holds port 80 on IPv4 and IPv6, and answers. If you need both programs, give one of them another port instead.

When the port belongs to “systemd”

Sometimes the owner is systemd with PID 1. On Ubuntu 26.04 and 24.04 that is the case for SSH:

Server
$ sudo ss -tlnp 'sport = :22'State  Recv-Q  Send-Q   Local Address:Port   Peer Address:Port ProcessLISTEN 0       4096           0.0.0.0:22          0.0.0.0:*     users:(("sshd",pid=1298,fd=3),("systemd",pid=1,fd=190))LISTEN 0       4096              [::]:22             [::]:*     users:(("sshd",pid=1298,fd=4),("systemd",pid=1,fd=191))
Output hidden (3 lines)
Server
$ systemctl list-sockets --no-pager | grep ssh0.0.0.0:22                                      ssh.socket                           ssh.service[::]:22                                         ssh.socket                           ssh.service/run/ssh-unix-local/socket                      sshd-unix-local.socket               -
Output hidden (3 lines)

This is socket activation: systemd itself listens on the port through a .socket unit (ssh.socket) and hands connections to the program (ssh.service). So the unit to look at is the socket, which systemctl list-sockets names. Never stop ssh.socket on a server you reach over SSH: new logins would fail.

Troubleshooting

  • ss shows the port but no process: run it with sudo. Details.
  • Nginx “installed fine” but is not running: apt printed the start failure in the middle of its output and still finished without an error. Check with systemctl is-active nginx. Details.
  • The port is busy again after a reboot: the other program’s service is still enabled. Use systemctl disable --now, not only stop. Details.
  • The owner is systemd, PID 1: a .socket unit listens there; systemctl list-sockets names it. Details.

What these steps changed on the server

Both runs recorded the server before the first step and after the last (see the Tested on box below): the Nginx packages were added, Apache’s boot link was removed, and Nginx, not Apache, listens on port 80.

Ubuntu 26.04 vs 24.04

The same check ran on a fresh 26.04 server and on a fresh 24.04 server, each with its own run log. Only the Nginx package’s install message differed:

WhatUbuntu 26.04Ubuntu 24.04
SystemUbuntu 26.04.1 LTS7.0.0-30-genericUbuntu 24.04.4 LTS6.8.0-138-generic
nginx1.28.3-2ubuntu1.121.24.0-2ubuntu7.19
apache22.4.66-2ubuntu2.82.4.58-1ubuntu8.19
iproute26.19.0-1ubuntu1.16.1.0-1ubuntu6.4
lsof4.99.4+dfsg-2build24.95.0-1build3
psmisc23.7-2ubuntu223.7-1build1
What the Nginx install prints when port 80 is takenFailed to start NGINX in postinst script (it tried)Not attempting to start NGINX, port 80 is already in use.
ProofRun log, 22 checks passedRun log, 22 checks passed

Undo: give port 80 back to Apache

Server
$ sudo systemctl stop nginx && sudo systemctl enable --now apache2Synchronizing state of apache2.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.Executing: /usr/lib/systemd/systemd-sysv-install enable apache2Created symlink '/etc/systemd/system/multi-user.target.wants/apache2.service' → '/usr/lib/systemd/system/apache2.service'.
Output hidden (3 lines)