Tag: reload

how to reload ngnix without restart for a configuration change?

To reload Nginx after making configuration changes without restarting or dropping connections, you can use the following command:

sudo nginx -s reload

Explanation:

  • This command tells the running Nginx master process to gracefully reload its configuration.
  • It does not terminate existing connections.
  • New worker processes are spawned using the new configuration, and the old ones are shut down gracefully after serving ongoing requests.

Alternative (Systemd-managed systems)

If you’re on a system using systemd (most modern Linux distros like Ubuntu, CentOS 7+, Debian, etc.):

sudo systemctl reload nginx

Equivalent behavior — reloads configuration without restarting the entire service.

Before reloading — test your config:

Always validate the configuration file syntax before reloading:

sudo nginx -t

If it shows:

nginx: configuration file /etc/nginx/nginx.conf test is successful

Then you can safely reload.

Summary

CommandPurpose
sudo nginx -tTest configuration for syntax errors
sudo nginx -s reloadGracefully reload config (no restart)
sudo systemctl reload nginxSame as above, via systemd