I am getting an error during Renewing an existing certificate

My domain is: api.arvindpatilnilangekar.com

I ran this command: sudo certbot --nginx -d api.arvindpatilnilangekar.com -d www.api.arvindpatilnilangekar.com

It produced this output:
Encountered exception during recovery: certbot.errors.MisconfigurationError: nginx restart failed:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)

My web server is (include version): Ubuntu

The operating system my web server runs on is (include version): Ubuntu 22.04.3 LTS

My hosting provider, if applicable, is: hostinger

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel):
no
The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): certbot 1.21.0

Hi @Zaigham0786, and welcome to the LE community forum :slight_smile:

What shows?:
netstat -pant | grep -i listen

3 Likes
tcp    0  0 127.0.0.1:3306    0.0.0.0:*   LISTEN  646/mysqld
tcp    0  0 0.0.0.0:22        0.0.0.0:*   LISTEN  40856/sshd: /usr/sb
tcp    0  0 127.0.0.1:65529   0.0.0.0:*   LISTEN  460/monarx-agent
tcp    0  0 127.0.0.53:53     0.0.0.0:*   LISTEN  395/systemd-resolve
tcp    0  0 127.0.0.1:33060   0.0.0.0:*   LISTEN  646/mysqld
tcp    0  0 127.0.0.1:631     0.0.0.0:*   LISTEN  38312/cupsd
tcp6   0  0 ::1:631           :::*        LISTEN  38312/cupsd
tcp6   0  0 :::80             :::*        LISTEN  40302/apache2
tcp6   0  0 :::22             :::*        LISTEN  40856/sshd: /usr/sb
tcp6   0  0 :::443            :::*        LISTEN  40302/apache2
tcp6   0  0 ::1:3350          :::*        LISTEN  544/xrdp-sesman
tcp6   0  0 :::3389           :::*        LISTEN  583/xrdp

Apache is using port 80.

And you are trying to use nginx on that same port:

Try using --apache instead:

sudo certbot --apache -d api.arvindpatilnilangekar.com -d www.api.arvindpatilnilangekar.com
4 Likes

now i am getting this error message

Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

AH00526: Syntax error on line 25 of /etc/apache2/sites-enabled/api.arvindpatilnilangekar.com.conf:
Name duplicates previous WSGI daemon definition.

Also, the recommended installation for Ubuntu 22 are via snap [not apt}:

For installation instructions see: Certbot (eff.org)

4 Likes

my conf file

<VirtualHost *:80>
    ServerName www.api.arvindpatilnilangekar.com
    ServerAlias api.arvindpatilnilangekar.com
    ServerAdmin contact@arvindpatilnilangekar.com

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static /var/www/apn/static
    <Directory /var/www/apn/static>
        Require all granted
    </Directory>

    Alias /media /var/www/apn/media
    <Directory /var/www/apn/media>
        Require all granted
    </Directory>

    <Directory /var/www/apn/apn>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess backend python-home=/var/www/apn/res python-path=/var/www/apn
    WSGIProcessGroup backend
    WSGIScriptAlias /  /var/www/apn/apn/wsgi.py
</VirtualHost>

again getting this error :Deploying certificate
Successfully deployed certificate for api.arvindpatilnilangekar.com to /etc/apache2/sites-available/api.arvindpatilnilangekar.com-le-ssl.conf
Successfully deployed certificate for www.api.arvindpatilnilangekar.com to /etc/apache2/sites-available/api.arvindpatilnilangekar.com-le-ssl.conf
Successfully deployed certificate for backend.diwise.uk to /etc/apache2/sites-available/backend.diwise.uk-le-ssl.conf
Successfully deployed certificate for www.backend.diwise.uk to /etc/apache2/sites-available/backend.diwise.uk-le-ssl.conf
Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

AH00526: Syntax error on line 25 of /etc/apache2/sites-enabled/api.arvindpatilnilangekar.com.conf:
Name duplicates previous WSGI daemon definition.

We were unable to install your certificate, however, we successfully restored your server to its prior configuration.

got this but my website didnt get any ssl
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/api.arvindpatilnilangekar.com-0001/fullchain.pem
Key is saved at: /etc/letsencrypt/live/api.arvindpatilnilangekar.com-0001/privkey.pem
This certificate expires on 2024-02-07.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.


If you like Certbot, please consider supporting our work by:

It looks like it was able to get a cert - but unable to install it [into Apache - because of the WSGI code]

What shows?:
certbot certificates

2 Likes
  Certificate Name: api.arvindpatil.com
    Serial Number: 4108057ab78de45a5c84499333c9ccf44c5
    Key Type: RSA
    Domains: api.arvindpatil.com
    Expiry Date: 2024-02-01 04:56:20+00:00 (VALID: 83 days)
    Certificate Path: /etc/letsencrypt/live/api.arvindpatil.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/api.arvindpatil.com/privkey.pem
  Certificate Name: api.arvindpatilnilangekar.com-0001
    Serial Number: 34a800aaaba701300ef88c0bcbee22a9249
    Key Type: ECDSA
    Domains: api.arvindpatilnilangekar.com
    Expiry Date: 2024-02-07 06:27:12+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/api.arvindpatilnilangekar.com-0001/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/api.arvindpatilnilangekar.com-0001/privkey.pem
  Certificate Name: api.arvindpatilnilangekar.com
    Serial Number: 3a0663ab6bd5727f678829ef34d14a3aae6
    Key Type: ECDSA
    Domains: api.arvindpatilnilangekar.com backend.diwise.uk www.api.arvindpatilnilangekar.com www.backend.diwise.uk
    Expiry Date: 2024-02-07 06:51:45+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/api.arvindpatilnilangekar.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/api.arvindpatilnilangekar.com/privkey.pem
  Certificate Name: www.api.arvindpatil.com
    Serial Number: 4d336b8483fb7fc590c880ab16b19425b19
    Key Type: RSA
    Domains: www.api.arvindpatil.com
    Expiry Date: 2024-02-01 04:56:52+00:00 (VALID: 83 days)
    Certificate Path: /etc/letsencrypt/live/www.api.arvindpatil.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/www.api.arvindpatil.com/privkey.pem
  Certificate Name: www.arvindpatil.com
    Serial Number: 4220a40dd99688cb7e3f955698d91fc1c6d
    Key Type: RSA
    Domains: www.arvindpatil.com
    Expiry Date: 2024-01-31 11:09:40+00:00 (VALID: 83 days)
    Certificate Path: /etc/letsencrypt/live/www.arvindpatil.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/www.arvindpatil.com/privkey.pem

You should look at this post for explanation

And follow its link to this one with likely solution

4 Likes

i have tried that but my error not got fixed
i am not getting my page now
and getting this error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at contact@arvindpatilnilangekar.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.


Apache/2.4.52 (Ubuntu) Server at api.arvindpatilnilangekar.com Port 80

please help

Hmm. I can reach your site using HTTP (port 80) although get a 404 Not Found for your home page. But, an internal server error is usually something like a 500 error.

What URL were you trying which got that error?

I see you have gotten many certs so you have no problem with that. In fact, you have gotten about 14 Let's Encrypt certs for this api domain in just the past few days (mixed with various other domain names).

Your problem is your Apache server is not configured properly.

And, your latest error is for port 80 (HTTP) which is not related to certificates at all. I am not sure what you want us to do. Please explain in more words.

2 Likes

i want ssl on my main api i dont know how to configure apache2 for drf and https will you help me for that please

I think you will be better off a Django forum. Maybe the one below

You don't have any problem getting Let's Encrypt certs which is our main focus. We often help with common server config. Maybe someone here will be willing to help but we do not see this very often on this forum.

2 Likes

This post is unrelated to the problem posted.

This first cert is redundant - the second cert covers already that name:
[and they are of the same type]

Certificate Name: api.arvindpatilnilangekar.com-0001
        Key Type: ECDSA
         Domains: api.arvindpatilnilangekar.com   <<<<<<<<<<<<

Certificate Name: api.arvindpatilnilangekar.com
        Key Type: ECDSA
         Domains: api.arvindpatilnilangekar.com   <<<<<<<<<<<<
                  backend.diwise.uk
                  www.api.arvindpatilnilangekar.com
                  www.backend.diwise.uk

These two cert can probably be combined into one cert:
[if they serve the same content from the same folder]

Certificate Name: api.arvindpatil.com
        Key Type: RSA
         Domains: api.arvindpatil.com

Certificate Name: www.api.arvindpatil.com
        Key Type: RSA
         Domains: www.api.arvindpatil.com

This cert seems to be missing the base domain:

Certificate Name: www.arvindpatil.com
        Key Type: RSA
         Domains: www.arvindpatil.com
2 Likes