Question

Nginx Stopped Working after installing Let's Encrypt on Ubuntu 20.04

I tried to install Let’s Encrypt on my Ubuntu 20.04 by following this article: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04#step-4-%E2%80%94-obtaining-an-ssl-certificate and after installing Nginx stopped working and I can’t start Nginx anymore.

These are a few of the tests:

#sudo vim /etc/nginx/sites-enabled/mydomain
server {

  server_name domain.com www.domain.com;
#sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
#sudo systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
#sudo ufw status
Status: inactive

and certbot asked me: Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. I selected to redirect. And when I visit my site without https I get 502 Bad Gateway and when I go with https I get domain.com refused to connect.

Any help is appreciated and thanks in advance

Show comments

Submit an answer
Answer a question...

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!

Sign In or Sign Up to Answer

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.

Accepted Answer

I did sudo fuser -k 80/tcp and did service nginx restart and site is up again.

A big thanks to @bobbyiliev

Thanks a lot @bobbyiliev

When I do passenger startI get:

Could not start the Nginx engine:
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] still could not bind()

Also when I deploy using capistrano I have There are no Phusion Passenger-served applications running whose paths begin with '/home/deploy/domain'. so I did cd to that folder and did: passenger start --port 80 and got:

*** ERROR: the Nginx configuration that Phusion Passenger Standalone generated internally contains problems. The error message returned by the Nginx engine is:

    nginx: the configuration file nginx.conf syntax is ok
    nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
    nginx: configuration file nginx.conf test failed

This probably means that you have found a bug in Phusion Passenger Standalone. Please report this bug to our Github issue tracker: https://github.com/phusion/passenger/issues

In the bug report, please include this error message, as well as the contents of the file /tmp/passenger-standalone-2bstm0.log 

the command passenger start in the same folder give:

Could not start the Nginx engine:
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:3000 failed (98: Address already in use)
nginx: [emerg] still could not bind()

So for port 3000 I did sudo fuser -k 3000/tcp and now when I do sudo netstat -plant | grep 3000 there is nothing that is running.

I appreciate your help @bobbyiliev

@bobbyiliev appreciate your help

I don’t run apache, only Nginx and the output is

#sudo netstat -plant | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      201626/nginx: worke 
tcp        0      0 206.189.7.79:58618      104.21.71.15:80         TIME_WAIT   -                   
tcp6       0      0 :::80                   :::*                    LISTEN      201626/nginx: worke 

Any suggestions? Thanks in advance