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
: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:
Save the file, and ensure it has proper permissions:
After making these changes, test your Nginx configuration:
If it passes, reload Nginx to apply the changes:
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: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:Regards