GrepBoard/Manuals
605 manuals ·

Nginx bind() to 0.0.0.0:80 failed (98: Address already in use)

·Tested on Ubuntu 24.04.5 · Nginx 1.24.0 · iproute2 6.1.0 (ss) · reproduced on ports in the 18800 range·Test scope ↓·6 steps

Another process already listens on the port Nginx wants. Find it with ss, and see why a failed reload leaves the old configuration serving traffic.

If nginx -t passes but start or reload prints the line below, some other socket already listens on that address and port. The output here was reproduced on port 18800 instead of 80; on your server only the port number differs.

console
$ nginxnginx: [emerg] bind() to 0.0.0.0:18800 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:18800 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:18800 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:18800 failed (98: Address already in use)nginx: [emerg] bind() to 0.0.0.0:18800 failed (98: Address already in use)nginx: [emerg] still could not bind()

The same line appears five times, then still could not bind(). That is five bind attempts, and the error log gets the same six lines.

[1] Read the address and port from the message. 0.0.0.0:18800 means port 18800 on all IPv4 addresses.

[2] Find the process that listens on it with ss. Run it as root, or other users' process names are hidden.

console
# ss -tlnp 'sport = :18800'State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcessLISTEN 0      511          0.0.0.0:18800      0.0.0.0:*    users:(("nginx",pid=111019,fd=4),("nginx",pid=111018,fd=4))

pid= in the Process column is the owner. Here the name is nginx with two PIDs: the master and a worker share one socket, so Nginx is already running. More on checking ports in Check which process is listening on a port.

[3] What to do depends on the owner.

Process in ssMeaningAction
nginxNginx is already runningDon't start another; run nginx -s reload. If you were changing the config, see step 5
apache2, httpd, another serverAnother web server holds the portMove one of them to a different port, or stop it

Check the command line by PID before stopping anything. It may be someone else's service, so don't kill on the PID alone.

console
# ps -o pid,ppid,cmd -p 111018

[4] The most common cause is running nginx a second time while it is already up. If Nginx runs as a service, use the service manager (systemctl reload nginx) instead of calling the binary. For a master already running with the same config, a signal is enough.

console
# nginx -s reload

[5] A failure during reload behaves differently. This was reproduced by adding listen 18801; to the config while a Python socket held that port.

console
# ss -tlnp 'sport = :18801'State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcessLISTEN 0      5            0.0.0.0:18801      0.0.0.0:*    users:(("python3",pid=111065,fd=3))# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful# nginx -s reload# tail -n 3 /var/log/nginx/error.log2026/10/19 14:37:51 [emerg] 111018#111018: bind() to 0.0.0.0:18801 failed (98: Address already in use)2026/10/19 14:37:51 [emerg] 111018#111018: bind() to 0.0.0.0:18801 failed (98: Address already in use)2026/10/19 14:37:51 [emerg] 111018#111018: still could not bind()

Three things were confirmed:

  • nginx -t passes. It checks syntax and does not open the sockets, so the error only shows up on reload.
  • nginx -s reload only sends a signal, so its exit code is 0. Read the result in the error log.
  • After the failed reload the old master (PID 111018) and worker stay and keep answering with the previous configuration. curl localhost:18800 returned the same response as before.

A silently failed reload is easy to mistake for an applied change. In deploy scripts, grep error.log for [emerg] after reloading.

[6] Free the port or fix listen, then reload again. In the test, removing listen 18801; and reloading produced no error and a new worker (PID 111199).

console
# nginx -s reload# ps -ef | grep '[n]ginx: 'root      111018       1  0 14:37 ?        00:00:00 nginx: master process …nobody    111199  111018  0 14:38 ?        00:00:00 nginx: worker process

Analyze your Nginx log in the browser ↗ — nothing is uploaded.

#nginx#bind#ss