Complete Nginx commands reference — 25 commands across 3 categories. Quick reference cheat sheet for Linux & Unix.
nginx has almost no interactive interface — it is driven by a dozen command-line switches and a handful of signals to the master process — so this page is short but every row on it matters in an outage. The two things worth knowing cold are how to test a configuration before applying it and the difference between a fast stop and a graceful one.
| Shortcut | Action |
|---|---|
| nginx -h | print help for command-line parameters |
| nginx -c file | use an alternative configuration file instead of a default file |
| nginx -e file | use an alternative error log file to store the log instead of a default file (1.19.5) |
| nginx -g directives | set global configuration directives, for example, nginx -g "pid /var/run/nginx.pid |
| nginx -l port | enable nginx control REST API on a specified port or UNIX-domain socket (1.29.8). This |
| nginx -p prefix | set nginx path prefix, i.e. a directory that will keep server files |
| nginx -q | suppress non-error messages during configuration testing |
| nginx -s signal | send a signal to the master process. The argument signal can be one of: stop - shut down |
| nginx -t | test the configuration file: nginx checks the configuration for correct syntax, and then tries |
| nginx -T | same as -t, but additionally dump configuration files to standard output (1.9.2) |
| nginx -v | print nginx version |
| nginx -V | print nginx version, compiler version, and configure parameters |
| Shortcut | Action |
|---|---|
| kill -TERM | Fast shutdown |
| kill -QUIT | Graceful shutdown |
| kill -HUP | Changing configuration, keeping up with a changed time zone (only for FreeBSD and Linux) |
| kill -USR1 | Re-opening log files |
| kill -USR2 | Upgrading an executable file |
| kill -WINCH | Graceful shutdown of worker processes |
| Shortcut | Action |
|---|---|
| nginx -s reload | Reload config |
| nginx -s stop | Stop server |
| nginx -s quit | Graceful stop |
| systemctl status nginx | Check status |
| systemctl restart nginx | Restart |
| tail -f /var/log/nginx/access.log | Access log |
| tail -f /var/log/nginx/error.log | Error log |
nginx -t parses the configuration and reports the first error with a file and line number; running it before every reload is the difference between a typo and a site outage, because a reload with a broken config is refused and the old workers keep serving. nginx -T does the same and dumps the fully resolved configuration, includes and all, which is the quickest way to answer "which server block is actually handling this host". nginx -s reload then applies the change: the master process starts new workers with the new config and lets the old ones finish their connections.
nginx -s quit and kill -QUIT on the master PID stop nginx gracefully, letting in-flight requests complete. nginx -s stop and kill -TERM drop everything immediately. kill -WINCH gracefully shuts down only the workers, which is used during binary upgrades together with kill -USR2, the signal that starts a new master from an upgraded executable while the old one keeps running. kill -USR1 reopens log files after logrotate moves them, without touching connections.
On systemd hosts systemctl status nginx shows whether the service is up and the last few log lines, and systemctl restart nginx is the blunt instrument when a reload is not enough. tail -f /var/log/nginx/error.log is the first command to run when a site returns 502s — upstream connection errors land there — and tail -f /var/log/nginx/access.log confirms whether requests are arriving at all. nginx -V (capital V) lists compiled-in modules and configure flags, which settles "is the brotli module even built in" arguments.
reload keeps serving while new workers start with the new config. restart stops the process and starts it again, dropping connections for a moment.
If nginx -t fails, the reload is refused and the running configuration stays. Check the error log or run nginx -t yourself to see the message.
nginx -V prints the compiled-in default path, and nginx -T dumps the configuration actually loaded, including every included file.
USR1 (kill -USR1 on the master PID) reopens the log files. Most logrotate configs for nginx already send it.
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"