Report this

What is the reason for this report?

I cannot run nginx -t. I get an error that I cannot explain.

Posted on January 9, 2025

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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-22-04

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.