Nginx Won’t Start and How to Fix It (Beginner-Friendly Guide)
# Step 1 — Check Nginx Status
First, see the current status:
Look for:
-
Active: inactive (dead)
-
Failed to start messages
-
Errors at the bottom
Example output:
## Step 2 — Test Nginx Configuration
A common reason Nginx won’t start is a syntax error in the configuration.
Run:
You might see:
Fix any errors reported here before proceeding.
## Step 3 — Check for Port Conflicts
Nginx usually uses ports 80 (HTTP) and 443 (HTTPS). If another process is using the port, Nginx won’t start.
Check which process uses port 80:
Or:
If you see Apache, another Nginx instance, or any process using the port:
-
Stop the conflicting service:
-
Or change Nginx port in
/etc/nginx/sites-available/default
## Step 4 — Check Logs for Errors
Nginx logs are in /var/log/nginx/.
Check error log:
Look for:
-
Missing files (e.g., certificate, HTML)
-
Syntax errors in virtual host configs
-
Permission issues
## Step 5 — Fix Permission Issues
Nginx may fail to start if it cannot read files.
Check ownership and permissions:
For SSL certificates:
## Step 6 — Restart Nginx Safely
After fixing configuration and permissions:
Check status:
It should show:
Test by opening your website in a browser or:
## Step 7 — Check SELinux or Firewall (if applicable)
Sometimes Nginx cannot bind to ports due to security restrictions.
Check firewall
Allow HTTP/HTTPS:
Check SELinux (CentOS/RHEL)
If enabled, allow Nginx to bind ports:
## Step 8 — Remove Old PID Files
If Nginx was killed improperly, old PID file may block startup:
## Step 9 — Test Configuration After Every Change
Always test config before restarting:
If “syntax is ok” → restart Nginx safely.
## Step 10 — Beginner-Friendly Checklist
| Problem | Diagnosis | Fix |
|---|---|---|
| Nginx not running | systemctl status nginx | Read status message |
| Syntax error | nginx -t | Fix configuration |
| Port conflict | lsof -i :80 | Stop conflicting service |
| Permission issue | ls -l /var/www/html | Fix ownership/permissions |
| Firewall/SELinux | ufw status, sestatus | Allow ports / adjust SELinux |
| Old PID file | /var/run/nginx.pid | Remove and restart |
## Conclusion
Nginx not starting is a common problem but almost always fixable with careful troubleshooting. By following these beginner-friendly steps, you can:
-
Identify configuration errors
-
Resolve port conflicts
-
Fix file permission issues
-
Check firewall and SELinux restrictions
-
Restart Nginx safely
With these steps, your websites should be running again in no time.