1

I have installed nginx-full on debian9 and I cant start it. When I did.

sudo /etc/init.d/nginx start

I got

[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
failed!

I also tried sudo nginx -t and got

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

the output for the systemctl status nginx.service is:

$sudo 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-06-06 15:16:04 IST; 10min ago
     Docs: man:nginx(8)
  Process: 2305 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 2302 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 27844 (code=exited, status=0/SUCCESS)


Jun 06 15:16:02 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:02 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:03 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:03 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:04 debedx nginx[2305]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jun 06 15:16:04 debedx nginx[2305]: nginx: [emerg] still could not bind()
Jun 06 15:16:04 debedx systemd[1]: nginx.service: Control process exited, code=exited status=1
Jun 06 15:16:04 debedx systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Jun 06 15:16:04 debedx systemd[1]: nginx.service: Unit entered failed state.
Jun 06 15:16:04 debedx systemd[1]: nginx.service: Failed with result 'exit-code'.
  • 3
    Please add output from systemctl status nginx.service – Mikael Kjær Jun 6 '18 at 9:29
  • The correct way to ask your question should describe how you install nginx and with proper log as suggested by Mikael can you please edit your question to add a bit more information ? Also take the time to read the tour it will help you understand how this community work and how you can improve your question. – Kiwy Jun 6 '18 at 9:44
  • what about systemctl restart nginx.service ? – Kiwy Jun 6 '18 at 12:21
0

Looking at the output of systemctl status nginx.service, it seems that the port on which nginx is running is being used by other process.

You can check that using netstat -tulpn|grep 80 command. Once identified,

(1) Either change the port no. of nginx in it's configuration file by editing /etc/nginx/nginx.conf using an editor and set 'Listen <new_port_no.>'and start nginx (systemctl start nginx.service) or

(2) Kill that process if that process is not significant by issuing command and the start nginx. To know process id of the process, type: ps aux|grep <process name>

kill <process id>

Make sure what you are going to do before killing the process. Hence I would suggest you to change the port no. of nginx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.