Fix "nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)"
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
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.
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
- Apache installed and running (
apache2on Debian/Ubuntu,httpdon RHEL/Fedora), often installed along with PHP or a hosting panel. - Nginx already started outside systemd:
sudo nginxtyped by hand, thensystemctl start nginxtries to start a second one. - Docker container or another server (Caddy, Traefik, Node) publishing port 80 or 443 on the host.
- Double IPv4/IPv6 listen:
listen [::]:80 ipv6only=off;already covers IPv4, and alisten 80;next to it conflicts. - Windows: IIS, old Skype, or the Windows HTTP service (PID 4, "System") holds port 80.
Step-by-step fix
-
Find the process holding the port (Linux)
ssshows the name and PID of the listening program. Replace 80 with 443 if that is the failing port.sudo ss -ltnp 'sport = :80' # or sudo lsof -nP -iTCP:80 -sTCP:LISTEN -
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.sudo systemctl stop apache2 sudo systemctl disable apache2 -
An old Nginx? Stop it cleanly
If
ssshowsnginxwhile 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.sudo nginx -s quit # if it does not stop: sudo pkill -TERM nginx sudo systemctl start nginx systemctl status nginx --no-pager -
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.docker ps --format "table {{.Names}}\t{{.Ports}}" | grep -E ":(80|443)->" docker stop my-container -
Check the listen directives
Look for IPv4/IPv6 duplicates across the whole configuration. The standard form is
listen 80;pluslisten [::]:80;(withoutipv6only=off).sudo nginx -T 2>/dev/null | grep -nE "^\s*listen" sudo nginx -t && sudo systemctl restart nginx -
On Windows
Find the PID with
netstat, then its name withtasklist. If it is IIS, stop the World Wide Web Publishing service; otherwise make Nginx listen on another port (listen 8080;) for development.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 withsudo nginxdirectly. - On a server, install only one web server on ports 80/443; other applications listen on
127.0.0.1and an internal port. - Run
sudo nginx -tafter 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
- Fix "upstream timed out (110: Connection timed out)" and 504 Gateway Time-out in Nginx
- Fix "413 Request Entity Too Large" (Nginx, PHP, Express, Cloudflare)
- Fix "Certbot failed to authenticate some domains" (Let’s Encrypt, Timeout during connect, acme-challenge 404)
- Fix "Resource not accessible by integration" in GitHub Actions
- Fix the 404 on refresh of a SPA on Vercel ("404: NOT_FOUND"), Netlify and Nginx
- Fix "An error occurred (AccessDenied) when calling the PutObject operation" on AWS S3
- Fix "The connection to the server localhost:8080 was refused" with kubectl