The bind() to 0.0.0.0:80 failed (10013)
error occurs when Nginx cannot bind to port 80 because either:
- Another process is already using port 80
- Windows has reserved the port for system services
- Permission issues prevent Nginx from accessing the port
First, let's identify what's using port 80:
netstat -ano | findstr :80
If you see output like:
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
The number at the end (4 in this case) is the PID of the process using the port.
On Windows, these services often claim port 80:
- World Wide Web Publishing Service (IIS)
- SQL Server Reporting Services
- Skype (yes, really!)
- Other web servers like Apache
1. Stop Competing Services
For IIS (most common case):
net stop was /y
To prevent it from restarting:
sc config W3SVC start= disabled
2. Check for HTTP.SYS Port Reservation
Windows sometimes reserves ports via HTTP.SYS. Check reservations:
netsh http show urlacl
If you see entries for port 80, remove them:
netsh http delete urlacl url=http://+:80/
3. Nginx Configuration Adjustments
If you must keep other services on port 80, consider:
- Changing Nginx's listen port to something else (e.g., 8080)
- Using port forwarding with netsh:
netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=8080 connectaddress=127.0.0.1
To ensure this doesn't happen after reboots:
- Disable unnecessary services that might claim port 80
- Add Nginx as a Windows service with proper permissions
- Create a startup script that checks port availability
Here's a PowerShell script to automatically handle port conflicts:
# check_port.ps1
$portInUse = (Get-NetTCPConnection -LocalPort 80 -State Listen -ErrorAction SilentlyContinue)
if ($portInUse) {
Write-Host "Port 80 in use by PID $($portInUse.OwningProcess)"
$process = Get-Process -Id $portInUse.OwningProcess
if ($process.Name -eq "System") {
netsh http delete urlacl url=http://+:80/
}
Stop-Process -Id $portInUse.OwningProcess -Force
}
Start-Process "nginx.exe"
For production environments, consider using NSSM:
nssm install nginx
nssm set nginx Application "C:\nginx\nginx.exe"
nssm set nginx AppDirectory "C:\nginx"
nssm start nginx
The error message nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
typically occurs when another process is already using port 80 or when your user account lacks the necessary permissions.
First, let's identify if port 80 is already in use:
netstat -ano | findstr :80
This command will show you the Process ID (PID) of any application using port 80. Common culprits include:
- IIS (Microsoft's web server)
- Skype (sometimes uses port 80)
- Other web servers like Apache
- SQL Server Reporting Services
If you find a conflicting process, you have several options:
- Stop the competing service:
net stop was /y
This stops IIS if it's running.
- Change nginx's listening port:
Edit your nginx.conf file:server { listen 8080; server_name localhost; # ... rest of your config }
Windows sometimes reserves ports for specific services. Check with:
netsh interface ipv4 show excludedportrange protocol=tcp
If port 80 appears in the list, you can try releasing it:
netsh int ipv4 set dynamicport tcp start=49152 num=16384
netsh int ipv6 set dynamicport tcp start=49152 num=16384
Sometimes the issue is simply permission-related. Try:
- Right-click the nginx executable
- Select "Run as administrator"
Windows Firewall might be blocking nginx. Check with:
netsh advfirewall firewall show rule name=all
To add an exception:
netsh advfirewall firewall add rule name="Nginx" dir=in action=allow program="C:\nginx\nginx.exe" enable=yes
For persistent issues, you can explicitly grant permission:
netsh http add iplisten ipaddress=0.0.0.0
netsh http add urlacl url=http://+:80/ user=Everyone
After making changes, verify nginx can start:
nginx -t # Test configuration
start nginx # Start the server
Check if it's running:
tasklist /fi "imagename eq nginx.exe"