We may earn a referral fee at no additional cost to you when you shop through the links on this page.
You restarted nginx and systemd threw back Job for nginx.service failed because the control process exited with error code. On its own that message is a dead end: nginx started and quit, with no reason given. This DevAnswers guide goes to the real cause, which nginx -t usually names outright, or a port already in use.
Run nginx -t First
Before reading any logs, test the configuration. The -t flag does a syntax check and tries to open every file the config references, so it catches the typo or missing file that stopped nginx, and it prints the exact location:
sudo nginx -t
nginx: [emerg] unexpected "}" in /etc/nginx/sites-enabled/default:6
nginx: configuration file /etc/nginx/nginx.conf test failed
Open the file at that line, fix it (a missing ; or an unclosed { is the usual culprit), and restart:
sudo nginx -t && sudo systemctl restart nginx
Chaining the test with && means the restart only runs if the config is valid, so you never trigger the same failure twice. After it starts, confirm it is actually running and serving. If nginx -t reports syntax is ok but the service still will not start, the problem is not the config text, keep going.
Why the systemd Message Tells You Nothing
The wording is generic by design. systemd launched nginx, nginx exited with a non-zero code, and systemd reports only that the “control process exited”, not why. systemd itself points you at two places for the detail, systemctl status nginx and journalctl -xe, and nginx records its own reason in the error log. The real cause is always in one of those three, not in the headline message. To audit other units or see which processes are failing, you can list all systemd services on your machine.
Read the Specific Error
When nginx -t passes, pull the actual failure from the journal. The -x flag adds explanatory help text to the log entries and -e jumps to the end, so journalctl -xe shows the most recent events with context:
sudo journalctl -xe -u nginx.service
Then read nginx’s own log, where fatal startup problems are recorded at the [emerg] level (the most severe of nginx’s levels: debug, info, notice, warn, error, crit, alert, emerg):
sudo tail -n 30 /var/log/nginx/error.log
If you are not sure your log lives there, our guide to the nginx error and access log locations covers the defaults and how to find a custom path.
The Other Common Cause: Port Already in Use
If the error log shows a line like this, the config is fine, something else already holds the port:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Another process (often Apache, or a second nginx that did not fully stop) is listening on port 80. Find out which one:
sudo ss -ltnp 'sport = :80'
That prints the listening process and its PID. If it is a service such as Apache, stop it (and disable it so it does not grab the port again at boot), then start nginx:
sudo systemctl stop apache2
sudo systemctl disable apache2
sudo systemctl start nginx
httpd (so sudo systemctl stop httpd), and lsof -i :80 is an alternative to ss for finding the process holding the port. Troubleshooting
nginx -tis OK but it still won’t start. Sincenginx -talready opens the files your config references, a passing test usually points at a runtime problem rather than the config text, almost always the port conflict above, sometimes a permissions or environment issue. The[emerg]line in the error log names it.- The port is still taken after you stopped the service. The old process may not have released it, or a supervisor restarted it. Re-check with
sudo ss -ltnp 'sport = :80'; if the service came back,systemctl disableit as well as stopping it. - “Permission denied” in the log. nginx cannot read a file it references. Note the privilege split: nginx’s master process starts as root and reads the TLS certificate and private key at startup, so those stay root-owned, do not make a private key readable by the worker user. The worker user only needs read access to the content and configs it serves. Check ownership and that each referenced path exists.
- You want to see the whole resolved config.
sudo nginx -T(capital T) runs the same test as-tand also dumps the entire combined configuration, which is useful when anincludeis pulling in something unexpected.
Summary
The systemd message is just a wrapper; the real cause is one command away. Run sudo nginx -t first, it names the failing file and line. If that passes, read journalctl -xe -u nginx.service and /var/log/nginx/error.log, and watch for address already in use, which means another service has the port. Fix the root cause, then sudo nginx -t && sudo systemctl restart nginx to confirm nginx is back. If it is the restart command itself you want to double-check, see restarting nginx on Ubuntu.
Comments