Service nginx restart fail

Hi all!

When i do " sudo service nginx restart " , terminal says me: * Restarting nginx nginx [fail]

What can i do?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

After each modification in your nginx config file do : sudo nginx -t

It will tell you if there are any error in config file. If everything is ok, do : sudo service nginx reload

reload = nginx will reload your configuration, without restart. restart = stop and start again nginx. For some seconds, your website will be offline.

You can check your error log: cat /var/log/nginx/error.log (I think error.log is the default name)

Excuse me my bad english.

Just make sure the port that nginx is running on is not used by any other service.

Kill any service running on that port or just stop the service.

Hi, all

As some users already mentioned you should always examine the error_log in order to check what’s wrong with the configuration:

You can either tail or cat the file:

tail -f /var/log/nginx/error.log tail -n 200 /var/log/nginx/error.log cat /var/log/nginx/error.log

You can also check for any syntax errors:

sudo nginx -t

In newer OSs like CentOS 7 you can use use the journalctl command to see the logs that the journald daemon has collected.

When used alone, every journal entry that is in the system will be displayed within a pager (usually less) for you to browse. The oldest entries will be up top:


We have an existing tutorial on how to view and manipulate systemd logs.

Hope that this helps! Regards, Alex