Reputation: 1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost bin]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
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 (98: Address already in use)
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 (98: Address already in use)
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 (98: Address already in use)
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 (98: Address already in use)
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] still could not bind()
[root@localhost bin]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: **failed** (Result: exit-code) since Mon 2018-04-09 16:35:28 IST; 6min ago
Process: 22654 ExecStart=/usr/sbin/nginx (**code=exited, status=1/FAILURE**)
Process: 22597 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 22595 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Apr 09 16:35:27 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Apr 09 16:35:27 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] still could not bind()
Apr 09 16:35:28 localhost.localdomain systemd[1]: **Failed to start The nginx HTTP and reverse proxy server.**
Apr 09 16:35:28 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Apr 09 16:35:28 localhost.localdomain systemd[1]: nginx.service failed.
Error: Active: failed (Result: exit-code) since Mon 2018-04-09 16:35:28 IST; Process: 22654 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE) Apr 09 16:35:28 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Upvotes: 0
Views: 5233
Reputation: 31
The error basically means that some other application is using those default ports. You can check that using :
sudo netstat -tulpn
Get the PID of the process that already using that port and send signal with kill command.
sudo kill -2 <PID>
sudo service nginx restart
In my case apache httpd was running on the same port and I didn't want to kill that process so I changed the default port for nginx to some other port. This is how my nginx.conf
looks now.
server {
listen 3000 default_server;
listen [::]:3000 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Also, make sure that in this file, user
is set as the user you are logged in as ( for ex root
).
If this is not the case, you can try other options mentioned here.
You can use nginx -t
to test that the file nginx.conf
is in correct syntax.
Upvotes: 3