sudo certbot renew --standalone --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx'

Category: VPS Management

sudo certbot renew --standalone --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx'

Renew with a standalone server and service hooks

For renewals when nginx holds port 80: --standalone makes certbot run its own temporary web server on port 80 to answer the challenge, so nginx must be stopped first (--pre-hook) and started again after (--post-hook). The pre/post hooks bracket the whole run. Expect a brief downtime during the swap.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.