Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix "service nginx restart" failing

Sometimes the command to restart Nginx fails and your sites go offline. This guide shows how to find the cause and fix it. It needs root access, so it is for VPS and dedicated server users.

Web Hosting2 min read7 steps

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

  1. Connect to your server with SSH.
  2. Run:
systemctl status nginx

This shows if Nginx is running and prints the last messages.

  1. 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.

  1. Back up the file before you edit it.
  2. Open the file named in the message.
  3. Fix the line.
  4. Run nginx -t again 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.

Tip: Always run 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 -t to find setting mistakes.
  • Check for a busy port and a full disk.
  • Restart only after the test passes.