Problem description
When starting the nginx service, the following error occurred:
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] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) ...
Cause of the problem
There are many reasons for this problem. We will list our scenarios and solutions here.
First, the port is occupied
This is the most common reason. Port 80 is occupied, which leads to binding of nginx service.
Solution 1
Find the process occupying port 80 and end it.
Second, dual stack sockets for IPv6
This is a common problem in the transition period from IPv4 to IPv6. The following configuration will also cause the above error:
server { listen [::]:80 ipv6only=off; server_name dual-stack.example.com; } server { listen 0.0.0.0:80; server_name ipv4.example.com; }
With the IPv6 only = off option, the currently created socket is dual stack, and IPv4 will be mapped to IPv6. At this time, only one monitor can be created, and IPv4 can no longer be monitored.
Solution 2
Since we can’t monitor IPv4, and now it’s a dual stack, we can monitor IPv6 address safely (and ensure IPv4 access at the same time)
server { listen [::]:80 ipv6only=off; server_name dual-stack.example.com; } server { listen [::]:80; server_name ipv4.example.com; } # Because of the specific scenario, we cannot modify the configuration of the first Server # Of course, it is also possible to turn off the double stack.
Read More:
- Aliyunshield occupies port 80 error: Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
- Linux Error: bind error: Address already in use [How to Solve]
- nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
- How to Solve Error: Address already in use
- Nginx Startup Error: “/var/run/nginx/nginx.pid” failed” [How to Solve]
- [Solved] nginx: [error] open() “/usr/local/nginx/nginx.pid” failed (2: No such file or directory)
- [Solved] Error: listen EADDRINUSE: address already in use :::5000
- Nginx error: nginx: [error] invalid PID number ““ in “/run/nginx.pid“
- [Solved] Nginx Restart Error: /run/nginx.pid failed (2: No such file or directory)
- Nginx Error: nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /project/api/nginx.conf:
- Nginx Startup Error: Job for nginx.service failed because the control process exited with error code
- Nginx Error: Swap file “/etc/nginx/.nginx.conf.swp“ already exists
- [Solved] Window Redis Service Failed to Startup: bind No error
- [Solved] Web server failed to start. Port 8080 was already in use.
- Nginx Error: SSL: error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
- How to Fix No default.conf file in conf.d after Installing Nginx
- Restart and stop of nginx in Linux service
- [Solved] Nginx Startup Error: directive is not allowed here in
- Solve the problem of 404 Not Found error in nginx accessing dynamic interface
- How to Solve Error: “Hdaudio hdaudioc0d2: unable to bind codec”