↑ ↓ select, Enter open, Esc close

Test the nginx configuration and reload only on success

Caution: This command changes the system. Understand what it does before you run it.

root@server
nginx -t && systemctl reload nginx

Checks the configuration and reloads it with reload without dropping existing connections. The old workers finish their running requests while new workers take over with the new configuration. If the test fails, nothing happens and the service keeps running with the old configuration.

Note: On Plesk, manual changes to generated files are overwritten during the next reconfiguration. Custom directives belong in the domain’s additional nginx directives.

Also searched as

  • nginx reload config
  • reload nginx without downtime
  • apply nginx config changes
  • safely restart nginx

Related one-liners

All in nginx

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.