I get the following error when I try to run nginx -t
2025/01/09 14:43:42 [emerg] 231687#231687: open() “/etc/letsencrypt/options-ssl-nginx.conf” failed (2: No such file or directory) in /etc/nginx/sites-enabled/autoharponline.com:20 nginx: configuration file /etc/nginx/nginx.conf test failed
I went through the tutorial to install Letencrypt on nginx. I did everything there except be able to run this command. It seems the file does not exist but I have no idea what is supposed to exist there nor do I see anything that tells me what I should have in that file from any tutorial.
I have gone through the server block tutorial from here https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04
I still cannot run nginx -t
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey Christopher! 👋
The error is saying that Nginx is trying to load the file /etc/letsencrypt/options-ssl-nginx.conf
, but it doesn’t exist. This file is typically generated by Certbot when you configure SSL for your site.
Have you tried running the following command to ensure Certbot generates all required files, including options-ssl-nginx.conf
:
sudo certbot --nginx
This command will scan your Nginx configuration, obtain/renew certificates, and generate any missing SSL-related files.
If the file still doesn’t exist, you can create it manually with recommended settings. Use this content:
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
Save the file, and ensure it has proper permissions:
sudo chmod 644 /etc/letsencrypt/options-ssl-nginx.conf
After making these changes, test your Nginx configuration:
sudo nginx -t
If it passes, reload Nginx to apply the changes:
sudo systemctl reload nginx
Let me know how it goes!
- Bobby
Heya,
The error 2025/01/09 14:43:42 [emerg] 231687#231687: open() “/etc/letsencrypt/options-ssl-nginx.conf” failed (2: No such file or directory) in /etc/nginx/sites-enabled/autoharponline.com:20 nginx: configuration file /etc/nginx/nginx.conf test failed
State the file on Line 20 which is mentioned in /etc/nginx/sites-enabled/autoharponline.com
does not exists. Try and run Certbot again:
sudo certbot --nginx
Heya, @christopherklecker
As mentioned if the file in question does not exist you can manually create it and then set the proper permissions.
You can also check our tutorial on how to secure Nginx with Let’s Encrypt
Also certbot
automatically sets up a cron job or systemd timer for renewal, but you can manually test it by running:
sudo certbot renew --dry-run
Regards
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.