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.
https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs
Hope that this helps!
Regards,
Alex

by Justin Ellingwood
Some of the most compelling advantages of systemd are those involved with process and system logging. Using other systems, logs are usually dispersed throughout the system, handled by different daemons and tools, and can be fairly difficult to interpret when they span...
Solved:
This error occurs when editing the nginx.conf something goes wrong and nginx can’t restart. The “nginx -t” It is very useful to resolve these errors when you edit nginx.conf,
Thanks to all!!
Thank you very much. It helped me finding out error in configuration file.
Thanks! it was so helpful to me too.
*nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
This was my response and yet it still won’t start
@bgarrison25 I had the same problem. Check nginx’s error logs (/var/log/nginx/error.log, or find the location in nginx.conf error_log).
In my case I had:
2015/12/29 12:33:37 [emerg] 24489#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/12/29 12:33:37 [emerg] 24489#0: still could not bind()
There was a port conflict in my conf. I was transitioning the server from apache > nginx, setting up nginx to run on a different port while apache still served live sites. By default, sites listen on 80 (which was in use by apache). Adding a “listen [port#];” with my temporary non-80 port to the site’s server block fixed it.
This was in fact my issue @palpants . I had my apache server still listening on port 80…durrr....figured it out a long time ago but forgot i even had this question here. Thanks!
Even after all this time, I found this post and the -t command is very useful in resolving simple nginx startup issues. Thanks
very helpful, thanks!
For me, the port was already in use by my node server. I found that server by running “pm2 list”, then stopped it with “pm2 stop myapp”.
@ joshnoe your solution worked for me too. I had no idea I have to stop my apps. Thanks a lot!