Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx: Failed to start A high performance web server and a reverse proxy server

Tags:

nginx

I try to start this service but i can´t, the error below occur:

root@zabbix:/home/appliance# systemctl status nginx.service

nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-07-25 18:33:26 UTC; 1min 27s ago
  Process: 30040 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 30037 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] still could not bind()
Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Control process exited, code=exited status=1

Jul 25 18:33:26 zabbix systemd[1]: *******Failed to start A high performance web server*** and a reverse proxy server.****

Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Unit entered failed state.
Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Failed with result 'exit-code'.
like image 219
Cibele Avatar asked Jul 25 '18 18:07

Cibele


3 Answers

You already have a process bound to the HTTP port 80. (Specially after upgrading systems! it will start apache2 by default)

So first try this:

sudo service apache2 stop
sudo systemctl restart nginx

If problem is not solved then run this command sudo lsof -i:80 to get a list of processes using the port and then stop or disable web server.

Try to stop the process which are using the port 80 using:

sudo fuser -k 80/tcp
sudo systemctl restart nginx

In some cases it may be some issues in the configuration file.

You can use nginx -t -c /etc/nginx/nginx.conf command to find any miss-configuration.

In some cases this error is caused by a default Nginx site already on port 80. Removing default config works if you don't need a default one!

sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
like image 198
Mahdi Younesi Avatar answered Nov 10 '22 16:11

Mahdi Younesi


For me this error was caused by a default nginx site already on port 80. Removing default site worked

sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
like image 26
frmbelz Avatar answered Nov 10 '22 18:11

frmbelz


You already have a process bound to the HTTP port 80. You can run command sudo lsof -i:80 to get a list of processes using the port and then stop/disable web server.

like image 32
Valery Viktorovsky Avatar answered Nov 10 '22 17:11

Valery Viktorovsky