# Certbot renew, passenger and nginx

**URL:** <https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664>\
**Category:** Server\
**Created:** [July 13, 2018, 2:46pm UTC](https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664 "2018-07-13T14:46:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveRedka](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@SteveRedka](https://community.letsencrypt.org/u/SteveRedka)\
**Post date:** [July 13, 2018, 2:46pm UTC](https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664/1 "2018-07-13T14:46:38Z")

</div>

Certbot tries to restart nginx whenever I ask it to renew certificates. I think it tries to treat it like it would treat nginx installed with apt-get, and it fails.

Passenger installs nginx into different directory (`/opt/nginx/sbin/nginx`), so I think this may be the problem.

This is how error looks like:

```auto
$ sudo certbot renew --dry-run # --post-hook "/etc/init.d/nginx restart"
Saving debug log to /var/log/letsencrypt/letsencrypt.log

-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/myapplication
.com.conf
-------------------------------------------------------------------------------
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator nginx, Installer nginx
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for myapplication
.com
http-01 challenge for www.myapplication
.com
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Encountered exception during recovery: 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 75, in handle_authorizations
    resp = self._solve_challenges(aauthzrs)
  File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 126, in _solve_challenges
    resp = self.auth.perform(all_achalls)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1048, in perform
    self.restart()
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 858, in restart
    nginx_restart(self.conf('ctl'), self.nginx_conf)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1118, in nginx_restart
    "nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/certbot/error_handler.py", line 108, in _call_registered
    self.funcs[-1]()
  File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 310, in _cleanup_challenges
    self.auth.cleanup(achalls)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1067, in cleanup
    self.restart()
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 858, in restart
    nginx_restart(self.conf('ctl'), self.nginx_conf)
  File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1118, in nginx_restart
    "nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''
Attempting to renew cert (myapplication
.com) from /etc/letsencrypt/renewal/myapplication
.com.conf produced an unexpected error: nginx restart failed:
b''
b''. Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/myapplication
.com/fullchain.pem (failure)

-------------------------------------------------------------------------------
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)

All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/myapplication
.com/fullchain.pem (failure)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
-------------------------------------------------------------------------------
1 renew failure(s), 0 parse failure(s)

```

Is there a workaround for that?

---

<div class="post-metadata">

**Author:** ![stevenzhu](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/stevenzhu/32/18864_2.png) [@stevenzhu](https://community.letsencrypt.org/u/stevenzhu)\
**Post date:** [July 13, 2018, 4:51pm UTC](https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664/2 "2018-07-13T16:51:54Z")

</div>

Hi,

Do you happen to have two set of Nginx installed? (E.x. one from default yum or apt-get, another one from passdgnger?)

Thank you

---

<div class="post-metadata">

**Author:** ![SteveRedka](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@SteveRedka](https://community.letsencrypt.org/u/SteveRedka)\
**Post date:** [July 13, 2018, 5:28pm UTC](https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664/3 "2018-07-13T17:28:19Z")

</div>

I did. Actually, I had three: one from passenger and two from apt packages (nginx and nginx-common).

However, I already removed them before asking this question.

---

<div class="post-metadata">

**Author:** ![schoen](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/schoen/32/79_2.png) [@schoen](https://community.letsencrypt.org/u/schoen)\
**Post date:** [July 13, 2018, 6:30pm UTC](https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664/4 "2018-07-13T18:30:28Z")

</div>

Perhaps these options will help you:

```auto
  --nginx-server-root NGINX_SERVER_ROOT
                        Nginx server root directory. (default: /etc/nginx or
                        /usr/local/etc/nginx)
  --nginx-ctl NGINX_CTL
                        Path to the 'nginx' binary, used for 'configtest' and
                        retrieving nginx version number. (default: nginx)

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [August 12, 2018, 6:30pm UTC](https://community.letsencrypt.org/t/certbot-renew-passenger-and-nginx/66664/5 "2018-08-12T18:30:32Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
