Created
April 1, 2018 09:31
-
-
Save mpolinowski/177e4cd4c3bdc516bfafffa7c133e84f to your computer and use it in GitHub Desktop.
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error Message: | |
``` | |
Redirecting to /bin/systemctl status -l nginx.service | |
● nginx.service - The nginx HTTP and reverse proxy server | |
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) | |
Active: failed (Result: exit-code) since Sat 2018-03-31 15:54:13 CEST; 16h ago | |
Process: 18761 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS) | |
Process: 13076 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE) | |
Process: 13072 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) | |
Process: 13070 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) | |
Main PID: 6121 (code=exited, status=0/SUCCESS) | |
Mar 31 15:54:12 CentOS-72-64-minimal nginx[13076]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) | |
Mar 31 15:54:12 CentOS-72-64-minimal nginx[13076]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) | |
Mar 31 15:54:12 CentOS-72-64-minimal nginx[13076]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use) | |
Mar 31 15:54:12 CentOS-72-64-minimal nginx[13076]: nginx: [emerg] bind() to [::]:443 failed (98: Address already in use) | |
Mar 31 15:54:12 CentOS-72-64-minimal nginx[13076]: nginx: [emerg] bind() to [::]:444 failed (98: Address already in use) | |
Mar 31 15:54:13 CentOS-72-64-minimal nginx[13076]: nginx: [emerg] still could not bind() | |
Mar 31 15:54:13 CentOS-72-64-minimal systemd[1]: nginx.service: control process exited, code=exited status=1 | |
Mar 31 15:54:13 CentOS-72-64-minimal systemd[1]: Failed to start The nginx HTTP and reverse proxy server. | |
Mar 31 15:54:13 CentOS-72-64-minimal systemd[1]: Unit nginx.service entered failed state. | |
Mar 31 15:54:13 CentOS-72-64-minimal systemd[1]: nginx.service failed. | |
``` | |
Solution: | |
[::]:80 is a ipv6 address. This error can be caused if you have a nginx configuration that is listening on port | |
80 and also on port [::]:80. I had the following in my default sites-available file: | |
``` | |
listen 80; | |
listen [::]:80 default_server; | |
``` | |
You can fix this by adding ipv6only=on to the [::]:80 like this: | |
``` | |
listen 80; | |
listen [::]:80 ipv6only=on default_server; | |
``` | |
__Make sure that only the default server listens over IPv6!__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment