Fix Nginx that will not start

We'll check config with nginx -t, inspect status with systemctl and journalctl, fix syntax and permission errors, and resolve port conflicts—or tell you when to escalate.

Category
Troubleshooting · Servers & Linux
Time
15–30 min
Last reviewed
What you'll need
  • SSH or console access with sudo

Step-by-step diagnostic

Step 1 of 6
Show full guide

Steps

Goal: Check config with nginx -t, inspect status and logs, fix syntax and permission errors, and resolve port conflicts.

  • Run sudo nginx -t to check config syntax. If it fails, fix the reported file and line.
  • Run systemctl status nginx and journalctl -u nginx -n 50 to see the error.
  • Good: You see the cause. Proceed to Check config syntax or Fix port conflict.
  • Bad: Run nginx in foreground (sudo nginx) to capture startup output.

Check config syntax

Goal: Confirm the config is valid before starting.

  • Run sudo nginx -t. Syntax errors (missing semicolons, unclosed braces, invalid directives) prevent start.
  • Good: “syntax is ok” and “test is successful”. Proceed to Check status and logs.
  • Bad: Fix the file and line reported. Run nginx -t again until it passes.

Check status and logs

Goal: See the current state and error from systemctl and journalctl.

  • Run systemctl status nginx for state. Run journalctl -u nginx -n 50 for the error.
  • Common causes: address already in use (port conflict), permission denied (config or log dirs), file not found.
  • Good: Error identified. Proceed to Fix port conflict or fix permissions.
  • Bad: Run sudo nginx in foreground to see startup output.

Fix port conflict

Goal: Free port 80 or 443 if another service uses it.

  • Run ss -tlnp or lsof -i :80 and lsof -i :443. Apache or another web server may be using the port.
  • Stop the conflicting service or change the Listen directive in nginx config.
  • Good: Port is free. Run sudo systemctl start nginx. Confirm you should see active (running).
  • Bad: If you cannot stop the conflicting service, change nginx to listen on a different port.

When to escalate

Escalate if:

  • Nginx is managed by config management.
  • The fix requires application-level changes.
  • You cannot safely modify the config.

Provide nginx -t output, systemctl status, and journalctl output.

Verification

  • sudo nginx -t reports “syntax is ok” and “test is successful”.
  • systemctl status nginx shows active (running).
  • No errors in journalctl -u nginx.
  • Nginx serves requests (e.g. curl localhost returns a response).

Escalation ladder

Work from the device outward. Stop when the problem is fixed.

  1. Config test nginx -t to check syntax.
  2. Status and logs systemctl status nginx; journalctl -u nginx.
  3. Fix config and permissions Fix syntax errors; chown/chmod for nginx user.
  4. Port conflicts ss -tlnp or lsof; stop conflicting service or change port.
  5. Escalate Provide nginx -t, status, journalctl.

What to capture if you need help

Before calling support or posting for help, have these ready. It speeds everything up.

  • nginx -t output
  • systemctl status nginx output
  • journalctl -u nginx -n 50 output
  • ss -tlnp or lsof -i :80 output (if port conflict)
  • Steps already tried

Does nginx -t pass?

Run sudo nginx -t. Syntax errors prevent start.

Run `sudo nginx -t`. Syntax error: fix the file and line reported, run nginx -t again. Test successful: config is valid—check systemctl status and journalctl for other causes (port, permissions).

You can change your answer later.

Fix config syntax

Edit the config file at the path nginx -t reported. Fix missing semicolons, unclosed braces, invalid directives. Run `sudo nginx -t` again. When syntax is ok, run `sudo systemctl start nginx`. Confirm you should see the service start.

What does journalctl show?

Read the last 50 lines of nginx logs.

Run `journalctl -u nginx -n 50`. Address already in use: check ss -tlnp or lsof -i :80; stop conflicting service or change port. Permission denied: chown/chmod for nginx user on config and log dirs. Other: check nginx -t and unit file.

You can change your answer later.

Apply fix

Port: stop Apache or other service using 80/443, or change Listen in nginx config. Permissions: chown nginx:nginx or chmod for config/log dirs. Syntax: fix config per nginx -t. Run systemctl start nginx. Confirm you should see active (running).

You can change your answer later.

Done

Nginx is active. Monitor with systemctl status nginx.

Test manually or escalate

Run `sudo nginx` (foreground) to see startup errors. Fix config or environment. If managed by config management, escalate with nginx -t, systemctl status, and journalctl output.

Reviewed by Blackbox Atlas

Frequently asked questions

Why would Nginx not start?
Config syntax error, port already in use, permission denied on config or log dirs, or missing modules. Run nginx -t and journalctl -u nginx first.
Can I fix Nginx that will not start myself?
Yes. Run nginx -t to find config errors, fix the config, check port conflicts with ss -tlnp, and confirm permissions. Reload with systemctl daemon-reload.
When should I escalate Nginx start failures?
If Nginx is managed by config management, the fix requires application-level changes, or you cannot safely modify the config.

Rate this guide

Was this helpful?

Thanks for your feedback.

Continue to