Skip to content

Let's Encrypt broke my nginx config

Web Hosting by prague1983 3 replies 182 views
4 #1

Certbot renewed last night and now nginx fails to start with "duplicate listen directive" errors. I checked /etc/nginx/sites-enabled/ and certbot duplicated the entire server block for port 443. Running on OVHcloud VPS. Yes I ran certbot as root because it needs to bind port 80, fight me.

Error log shows:
nginx: [emerg] duplicate listen 0.0.0.0:443 in /etc/nginx/sites-enabled/mysite-le-ssl.conf:12

Help before my site has been down for 3 hours

oops: 0000 [#1] SMP
1 #2

Pro tip: certbot with nginx plugin should handle this automatically but heads up, running as root changes file permissions in ways that break unattended renewal later.

Quick fix without the mess:

1. Stop nginx: sudo systemctl stop nginx
2. Remove the duplicate: sudo rm /etc/nginx/sites-enabled/mysite-le-ssl.conf
3. Restore from your backup of /etc/nginx/sites-available/mysite
4. Run: sudo certbot --nginx -d example.com --reinstall
5. Test: sudo nginx -t
6. Start: sudo systemctl start nginx

Check permissions with ls -l /etc/letsencrypt/archive/ afterward. Root-only means certbot cant auto-renew without root cronjob, which is a security headache you dont need.

licensing is a suggestion
#3

Which OS and nginx version?

swimming upstream since 2019 🐟
#4

> running as root changes file permissions

Yep

world record: 4min Arch install

Post a reply

You need an account to reply. Log in or register to join the conversation.

Post reply Preview Save draft