How to Start, Stop, or Restart Nginx

By 

Updated on

5 min read

Start, Stop, Restart Nginx

Nginx (pronounced “engine x”) is a free, open-source, high-performance HTTP and reverse proxy server responsible for handling the load of some of the largest sites on the Internet. It can be used as a standalone web server or as a reverse proxy for Apache and other web servers.

If you are a developer or system administrator, you are likely dealing with Nginx on a regular basis. Starting, stopping, and reloading are the most common tasks when working with an Nginx web server.

This guide explains how to start, stop, and restart Nginx on Linux servers.

Before You Begin

The instructions assume you are logged in as root or as a user with sudo privileges.

Most mainstream Linux distributions use systemd as the default init system and service manager. Both systemd and legacy SysVinit init scripts accept the following arguments to manage the Nginx service:

  • start — starts the Nginx service
  • stop — terminates the Nginx service
  • restart — stops and then starts the Nginx service
  • reload — gracefully reloads the configuration; the main process loads the new config and starts new worker processes without dropping active connections
  • status — shows the current service status

The commands for managing the Nginx service are the same across Linux distributions.

Start, Stop, and Restart Nginx Using systemctl

Use the systemctl command to control Nginx on systemd-based systems.

To check whether Nginx is currently running:

Terminal
sudo systemctl status nginx

To start the Nginx service:

Terminal
sudo systemctl start nginx

To stop the Nginx service:

Terminal
sudo systemctl stop nginx

To restart the Nginx service (stops and starts it):

Terminal
sudo systemctl restart nginx

Reloading vs. Restarting

When adding or editing server blocks, prefer reloading over restarting. A reload loads the new configuration and starts new worker processes without dropping active connections. A restart terminates all connections and starts fresh — use it only when making significant changes such as changing ports or network interfaces.

Before reloading, always test the configuration for syntax errors:

Terminal
sudo nginx -t

If the test passes, reload the service:

Terminal
sudo systemctl reload nginx

Nginx can also be reloaded directly using a signal:

Terminal
sudo nginx -s reload

After restarting or reloading, verify that Nginx is active and responding:

Terminal
sudo systemctl is-active nginx
curl -I http://localhost

Enable or Disable Autostart

To enable Nginx to start automatically on boot:

Terminal
sudo systemctl enable nginx

To disable autostart:

Terminal
sudo systemctl disable nginx

Start, Stop, and Restart Nginx Using service

Older systems may still use SysVinit init scripts to manage services. Use the service command on those systems.

To restart the Nginx service:

Terminal
sudo service nginx restart

To reload the Nginx service:

Terminal
sudo service nginx reload

To start the Nginx service:

Terminal
sudo service nginx start

To stop the Nginx service:

Terminal
sudo service nginx stop

Troubleshooting

Nginx fails to start after editing the configuration A syntax error in the configuration file prevents Nginx from starting. Run sudo nginx -t to identify the error before restarting or reloading. Fix the reported line, then retry.

Port 80 or 443 is already in use Another process is bound to the port. Check which process is using it with sudo ss -tlnp | grep ':80', then stop that service before starting Nginx.

Permission denied when starting Nginx Nginx requires elevated privileges to bind to ports below 1024. Make sure you are running the command with sudo, and that no file permission issues exist in the Nginx log or run directories.

systemctl reload fails silently after a config change Always run sudo nginx -t before reloading. If the configuration contains errors, reload will fail and the old configuration will remain active. Check sudo systemctl status nginx and journalctl for details.

Quick Reference

For a printable quick reference, see the systemctl cheatsheet .

CommandDescription
sudo systemctl start nginxStart Nginx
sudo systemctl stop nginxStop Nginx
sudo systemctl restart nginxStop and start Nginx
sudo systemctl reload nginxReload config without dropping connections
sudo systemctl status nginxShow service status
sudo systemctl enable nginxEnable autostart on boot
sudo systemctl disable nginxDisable autostart on boot
sudo nginx -tTest configuration for syntax errors
sudo nginx -s reloadReload using signal (alternative to systemctl)

FAQ

What is the difference between restart and reload? restart stops the Nginx process and starts it again, dropping all active connections. reload sends a signal to the main process to re-read the configuration and gracefully replace worker processes, keeping active connections alive. Use reload for routine configuration changes.

How do I check if Nginx is running? Run sudo systemctl status nginx. The output shows whether the service is active, the process ID, and recent log lines. You can also check with curl -I http://localhost.

How do I enable Nginx to start automatically on boot? Run sudo systemctl enable nginx. To confirm it is enabled, run sudo systemctl is-enabled nginx.

How do I safely reload Nginx after editing a config file? Always test the configuration first with sudo nginx -t. If the test reports “syntax is ok” and “test is successful”, run sudo systemctl reload nginx to apply the changes without dropping connections.

Conclusion

Use systemctl to start, stop, restart, reload, and manage the autostart behavior of Nginx on systemd-based Linux systems. Always run sudo nginx -t before reloading to catch configuration errors early. For related next steps, you can also review common Nginx operations and HTTP to HTTPS redirects in Nginx .

If you have any questions, feel free to leave a comment below.

Tags

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page