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


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

Bobby Iliev
Site Moderator
Site Moderator badge
January 21, 2021

Hi there,

I could suggest first checking your Nginx error log for some more information on why the service is crashing. You can do that with the following command:

  1. sudo tail -100 /var/log/nginx/error.log

Another thing you could do is to run the journalctl -xe as per the output of the Nginx start command.

Feel free to share the errors here. Regards, Bobby

Thanks @bobbyiliev for your reply

These are the complete outputs:

#sudo tail -100 /var/log/nginx/error.log
2021/01/21 10:28:55 [crit] 201626#201626: *43 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 128.14.134.170, server: domain.com, request: "GET / HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "206.189.7.79"
2021/01/21 10:29:00 [crit] 201626#201626: *42 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 77.16.221.12, server: domain.com, request: "GET / HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:32:56 [crit] 201626#201626: *47 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.234, server: domain.com, request: "GET /posts/painal-alert-dillion-harper-s-hardcore-anal-sex/s/1 HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:40:08 [crit] 201626#201626: *49 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.234, server: domain.com, request: "GET /posts/young-sexy-teen-nude-yoga/s/2 HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:47:01 [crit] 201626#201626: *51 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /snaps/girl-teasing-boobs-and-playing-with-panties-on HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:47:20 [crit] 201626#201626: *53 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.232, server: domain.com, request: "GET /posts/unbelievable-porn-stars-photos-before-and-after-applying-make-up-part-1/s/2 HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:51:34 [info] 202078#202078: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2021/01/21 10:51:35 [notice] 202081#202081: signal process started
2021/01/21 10:51:35 [error] 202081#202081: invalid PID number "" in "/run/nginx.pid"
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:35 [emerg] 202082#202082: still could not bind()
2021/01/21 10:51:38 [notice] 202083#202083: signal process started
2021/01/21 10:51:38 [error] 202083#202083: invalid PID number "" in "/run/nginx.pid"
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 10:51:38 [emerg] 202084#202084: still could not bind()
2021/01/21 10:52:02 [crit] 201626#201626: *55 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 77.16.221.12, server: domain.com, request: "GET / HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:52:30 [info] 202090#202090: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2021/01/21 10:54:32 [crit] 201626#201626: *58 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /posts/young-sexy-teen-nude-yoga/edit HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 10:54:54 [crit] 201626#201626: *61 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 77.16.221.12, server: domain.com, request: "GET / HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "www.domain.com"
2021/01/21 10:56:50 [crit] 201626#201626: *63 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 77.16.221.12, server: domain.com, request: "GET / HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:01:45 [crit] 201626#201626: *66 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /posts/unbelievable-porn-stars-photos-before-and-after-applying-make-up-part-3/edit HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:01:45 [crit] 201626#201626: *68 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.232, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:08:57 [crit] 201626#201626: *70 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:16:30 [crit] 201626#201626: *72 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 209.141.60.195, server: domain.com, request: "GET /config/getuser?index=0 HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "206.189.7.79:80"
2021/01/21 11:17:14 [crit] 201626#201626: *74 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 83.175.105.76, server: domain.com, request: "GET /snaps/20-years-old-bitch-fucked-in-club-toilet HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com", referrer: "https://www.google.com/"
2021/01/21 11:17:38 [crit] 201626#201626: *76 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:26:20 [crit] 201626#201626: *78 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:28:01 [crit] 201626#201626: *80 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 185.23.230.44, server: domain.com, request: "GET / HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "206.189.7.79:80"
2021/01/21 11:30:33 [crit] 201626#201626: *82 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:37:45 [crit] 201626#201626: *84 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:47:01 [crit] 201626#201626: *86 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 11:59:20 [crit] 201626#201626: *89 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
2021/01/21 12:02:15 [info] 202589#202589: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2021/01/21 12:03:38 [info] 202601#202601: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2021/01/21 12:03:38 [warn] 202601#202601: conflicting server name "domain.com" on [::]:80, ignored
2021/01/21 12:03:38 [warn] 202601#202601: conflicting server name "www.domain.com" on [::]:80, ignored
2021/01/21 12:03:38 [warn] 202616#202616: conflicting server name "domain.com" on [::]:80, ignored
2021/01/21 12:03:38 [warn] 202616#202616: conflicting server name "www.domain.com" on [::]:80, ignored
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:38 [emerg] 202616#202616: still could not bind()
2021/01/21 12:03:53 [info] 202628#202628: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2021/01/21 12:03:53 [warn] 202628#202628: conflicting server name "domain.com" on [::]:80, ignored
2021/01/21 12:03:53 [warn] 202628#202628: conflicting server name "www.domain.com" on [::]:80, ignored
2021/01/21 12:03:53 [warn] 202640#202640: conflicting server name "domain.com" on [::]:80, ignored
2021/01/21 12:03:53 [warn] 202640#202640: conflicting server name "www.domain.com" on [::]:80, ignored
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:03:53 [emerg] 202640#202640: still could not bind()
2021/01/21 12:05:40 [info] 202663#202663: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:63
2021/01/21 12:05:40 [warn] 202663#202663: conflicting server name "domain.com" on [::]:80, ignored
2021/01/21 12:05:40 [warn] 202663#202663: conflicting server name "www.domain.com" on [::]:80, ignored
2021/01/21 12:05:40 [warn] 202678#202678: conflicting server name "domain.com" on [::]:80, ignored
2021/01/21 12:05:40 [warn] 202678#202678: conflicting server name "www.domain.com" on [::]:80, ignored
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to [::]:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: bind() to 0.0.0.0:80 failed (98: Address already in use)
2021/01/21 12:05:40 [emerg] 202678#202678: still could not bind()
2021/01/21 12:13:44 [crit] 201626#201626: *92 connect() to unix:/tmp/passenger.NqSGkaJ/agents.s/core failed (2: No such file or directory) while connecting to upstream, client: 66.249.69.230, server: domain.com, request: "GET /robots.txt HTTP/1.1", upstream: "passenger:unix:/tmp/passenger.NqSGkaJ/agents.s/core:", host: "domain.com"
#journalctl -xe
Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 13.
Jan 21 09:42:42 Domain systemd[199844]: Listening on REST API socket for snapd user session agent.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 9.
Jan 21 09:42:42 Domain systemd[199844]: Listening on D-Bus User Message Bus Socket.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 10.
Jan 21 09:42:42 Domain systemd[199844]: Reached target Sockets.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 5.
Jan 21 09:42:42 Domain systemd[199844]: Reached target Basic System.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 2.
Jan 21 09:42:42 Domain systemd[199844]: Reached target Main User Target.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 1.
Jan 21 09:42:42 Domain systemd[199844]: Startup finished in 135ms.
-- Subject: User manager start-up is now complete
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The user manager instance for user 1000 has been started. All services queued
-- for starting have been started. Note that other services might still be starting
-- up or be started at any later time.
-- 
-- Startup of the manager took 135165 microseconds.
Jan 21 09:44:31 Domain sudo[200055]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jan 21 09:44:32 Domain sudo[200055]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jan 21 12:02:13 Domain sudo[202588]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory
Jan 21 12:02:15 Domain sudo[202588]: pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory

I’m really confused since it was working at first and it stopped suddenly.

Thanks in advance

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

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.