I have an NGINX webserver and I'm using Certbot (letsencrypt) to renew my websites certificates. When I try to renew certificates I have this error :

binding to port 80: Could not bind to IPv4 or IPv6

So I checked what was using port 80 and I got this :

# lsof -Pnl +M -i6
nginx   17117        0    7u  IPv6 102365521      0t0  TCP *:443 (LISTEN)
nginx   17117        0    9u  IPv6 102365523      0t0  TCP *:80 (LISTEN)
nginx   17118       33    7u  IPv6 102365521      0t0  TCP *:443 (LISTEN)
nginx   17118       33    9u  IPv6 102365523      0t0  TCP *:80 (LISTEN)
nginx   17119       33    7u  IPv6 102365521      0t0  TCP *:443 (LISTEN)
nginx   17119       33    9u  IPv6 102365523      0t0  TCP *:80 (LISTEN)
sshd    18455        0    4u  IPv6  66436292      0t0  TCP *:22 (LISTEN)

It seems 3 different nginx are running am I right ?

I tried to stop nginx by running

/etc/init.d/nginx stop

I also tried like this

systemctl stop nginx

And when I check current process I still have 2 nginx running no matter if I run the above stop commands :

root     17117  0.0  0.1 161720  2284 ?        Ss   juin06   0:00 nginx: master process nginx -c /etc/nginx/nginx.conf
www-data 17118  0.0  0.3 161984  8208 ?        S    juin06   0:00 nginx: worker process
www-data 17119  0.0  0.3 161720  7484 ?        S    juin06   0:02 nginx: worker process

By the way I cannot start NGINX because I have got this error :

# 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.

If someone can help me it would be nice :) !

  • Could you check systemctl status 17117? Maybe you started it manually, i.e. bypassing the service system. – user1686 Jun 7 '19 at 10:28
  • It says it is active (running). I killed the process and start Nginx again and I noticed that I cannot stop it even if I run the stop command. So when Certbot try to renew certificates it stops nginx (not working) renew certificates and then start nginx but because it is already started ther is an error... – Antoine Jun 7 '19 at 12:08
  • That wasn't quite what I meant. Look at which unit it is running inside. Is the process shown under nginx.service, or is it shown under something like cron.service or session-5.scope? – user1686 Jun 7 '19 at 12:29
  • It is shown under session-15634.scope : Loaded: loaded (/run/systemd/transient/session-15634.scope; transient; vendor preset: enabled) – Antoine Jun 7 '19 at 12:39

For systemd to successfully manage (stop or restart) a service, it must have been started via systemd. If an nginx process has been started directly, systemctl will not recognize it and will try to start a second copy, or will be unable to stop the existing copy.

Do not use /etc/init.d or sudo nginx to start services – always use systemctl start nginx. Make sure your cronjobs or Certbot hooks do the same thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.