Skip to content
  1. LuzineDebug
  2. DevOps, servers & cloud
  3. nginx: [emerg] bind() to 0.0.0.0:80 failed (98:…
DevOps, servers & cloud Beginner ≈ 5 min to fix

Fix "nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)"

Error message
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
  • nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
  • nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  • nginx: [emerg] bind() to 0.0.0.0:80 failed (10048: Only one usage of each socket address (protocol/network address/port) is normally permitted)
  • Job for nginx.service failed because the control process exited with error code.
  • nginx.service: Control process exited, code=exited, status=1/FAILURE
In short

Another program is already listening on port 80 (or 443): often Apache, a second Nginx instance started by hand, or a Docker container. Find it with sudo ss -ltnp 'sport = :80', stop it, then start Nginx with sudo systemctl start nginx.

Be the first to confirm this fix

What this error means

On startup, Nginx opens a socket on every address and port declared by its listen directives. The system only lets one process listen on a given address and port: if the port is already taken, the bind() system call fails with error 98 EADDRINUSE (10048 on Windows). Nginx retries a few times over a few seconds, then gives up with still could not bind(), and systemd marks the service as failed. The process holding the port can also be… an old Nginx still running.

Common causes

  1. Apache installed and running (apache2 on Debian/Ubuntu, httpd on RHEL/Fedora), often installed along with PHP or a hosting panel.
  2. Nginx already started outside systemd: sudo nginx typed by hand, then systemctl start nginx tries to start a second one.
  3. Docker container or another server (Caddy, Traefik, Node) publishing port 80 or 443 on the host.
  4. Double IPv4/IPv6 listen: listen [::]:80 ipv6only=off; already covers IPv4, and a listen 80; next to it conflicts.
  5. Windows: IIS, old Skype, or the Windows HTTP service (PID 4, "System") holds port 80.

Step-by-step fix

  1. Find the process holding the port (Linux)

    ss shows the name and PID of the listening program. Replace 80 with 443 if that is the failing port.

    bash
    sudo ss -ltnp 'sport = :80'
    # or
    sudo lsof -nP -iTCP:80 -sTCP:LISTEN
  2. Stop Apache if it is there

    If you want Nginx as the only web server, stop Apache and disable its automatic start. On RHEL/Fedora, the service is called httpd.

    bash
    sudo systemctl stop apache2
    sudo systemctl disable apache2
  3. An old Nginx? Stop it cleanly

    If ss shows nginx while the service is failed, an instance is running outside systemd. Stop it, then start it again through systemd so everything is managed in one place.

    bash
    sudo nginx -s quit
    # if it does not stop:
    sudo pkill -TERM nginx
    sudo systemctl start nginx
    systemctl status nginx --no-pager
  4. A Docker container?

    Find the container publishing the port, stop it or change its mapping (for example 8080:80) and let Nginx on the host proxy to it.

    bash
    docker ps --format "table {{.Names}}\t{{.Ports}}" | grep -E ":(80|443)->"
    docker stop my-container
  5. Check the listen directives

    Look for IPv4/IPv6 duplicates across the whole configuration. The standard form is listen 80; plus listen [::]:80; (without ipv6only=off).

    bash
    sudo nginx -T 2>/dev/null | grep -nE "^\s*listen"
    sudo nginx -t && sudo systemctl restart nginx
  6. On Windows

    Find the PID with netstat, then its name with tasklist. If it is IIS, stop the World Wide Web Publishing service; otherwise make Nginx listen on another port (listen 8080;) for development.

    powershell
    netstat -ano | findstr :80
    tasklist /FI "PID eq 1234"
    net stop w3svc

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Always start and stop Nginx with systemctl, never with sudo nginx directly.
  • On a server, install only one web server on ports 80/443; other applications listen on 127.0.0.1 and an internal port.
  • Run sudo nginx -t after every configuration change, before reloading.

Frequently asked questions

nginx -t says the configuration is fine, why does startup fail?

nginx -t checks syntax, not port availability. The bind() error only shows up at actual startup, when the port is already taken.

Can I run Apache and Nginx together?

Yes, on different ports: for example Nginx on 80/443 in front, and Apache on 127.0.0.1:8080 behind it, with proxy_pass http://127.0.0.1:8080;.

What about "bind() to 0.0.0.0:80 failed (13: Permission denied)"?

That is not a busy port: Nginx is started without the root privileges needed for ports below 1024. Start it with sudo systemctl start nginx.

Useful tools for this error

More DevOps, servers & cloud errors

All DevOps, servers & cloud errors →