What is Nginx?
Nginx is a web server. It is the program that answers visitors and sends them your pages. When you change its settings, you restart it. If a restart fails, Nginx stays off and your website does not load.
Step 1: Read the error
- Connect to your server with SSH.
- Run:
systemctl status nginx
This shows if Nginx is running and prints the last messages.
- For more detail, run:
journalctl -xe
This shows the newest system log lines. Press q to leave.
Step 2: Test the settings
Most failures come from a typing mistake in a settings file.
nginx -t
This checks all settings without starting anything. It tells you the file and line with the problem. Typical mistakes are a missing semicolon, a missing curly bracket, or a wrong file path.
- Back up the file before you edit it.
- Open the file named in the message.
- Fix the line.
- Run
nginx -tagain until it says the test is successful.
Step 3: Check if the port is busy
A port is a numbered door on the server. Web traffic uses doors 80 and 443. If another program holds one, Nginx cannot start. You may see "Address already in use".
ss -tlnp | grep -E ':80|:443'
This lists which program is using those doors. Often it is Apache. Stop the other program, or change one of them to a different port.
Step 4: Check the disk
A full disk can also stop Nginx. Check it:
df -h
If a disk shows 100 percent, free up space. Old log files are a common cause. Do not delete files you are unsure about.
Step 5: Start it again
systemctl restart nginx
This restarts Nginx. Then check your website in a browser.
nginx -t before every restart. It catches mistakes before they take your site down.Quick recap
- Read the error with
systemctl status nginx. - Run
nginx -tto find setting mistakes. - Check for a busy port and a full disk.
- Restart only after the test passes.