Set Up Let's Encrypt SSL for ERPNext
ERPNext can be secured with a free Let's Encrypt SSL certificate using the built-in bench command. Certificates are valid for 90 days and can be renewed automatically.
Prerequisites
- A valid domain name pointing to the server's IP
- Root or sudo access
- ERPNext installed with Nginx
- Port 80 open in the firewall
Steps
# Run the Let's Encrypt setup for a site
sudo -H bench setup lets-encrypt [site-name]
# For a custom domain
sudo -H bench setup lets-encrypt [site-name] --custom-domain [custom-domain]
Follow the interactive prompts. The command registers the site with Let's Encrypt, downloads the certificate, configures Nginx, and adds a monthly cron job for renewal.
Renew Manually
sudo bench renew-lets-encrypt
Notes
- Certificates expire every 90 days — automatic renewal via cron is set up by the command.
- Ensure your DNS record resolves correctly before running the command.
- For production, always run bench as a non-root user with appropriate sudo rights.