522 Error trying to use certbot for a Nextcloud server

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: mgnet.cloud

I ran this command: sudo certbot --apache

It produced this output:

Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.


1: mgnet.cloud


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Requesting a certificate for mgnet.cloud

Certbot failed to authenticate some domains (authenticator: apache). The Certificate Authority reported these problems:
Domain: mgnet.cloud
Type: unauthorized
Detail: 2606:4700:3031::6815:4744: Invalid response from http://mgnet.cloud/.well-known/acme-challenge/YtQ-UA3vLto6A9YOefdKF94RUz31Zqvtsz_L5yQWduE: 522

Hint: The Certificate Authority failed to verify the temporary Apache configuration changes made by Certbot. Ensure that the listed domains point to this Apache server and that it is accessible from the internet.

Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

My web server is (include version): apache 2.4.54

The operating system my web server runs on is (include version): Debian 11

My hosting provider, if applicable, is:

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

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): 1.32.0

Welcome to the community @matterofact

You proxied your Cloudflare DNS so are using their CDN. The 522 error is a problem between the Cloudflare CDN Edge and your Origin Server.

Please refer to the Cloudflare docs for suggestions
https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors

It is interesting that I get different behavior depending on the initial request

If I try your home page using HTTP I get redirected by Cloudflare to HTTPS and that fails with 522.

But, if I use a URL similar to the HTTP Challenge I get the 522 directly

Still, basic comms between the Edge and your Origin Server is not working well.

URL like HTTP Challenge:
curl -i http://mgnet.cloud/.well-known/acme-challenge/Test123
HTTP/1.1 522
Server: cloudflare

Home page starting with http gets 301 redirect
curl -i http://mgnet.cloud
HTTP/1.1 301 Moved Permanently
Location: https://mgnet.cloud/
Server: cloudflare

Following the redirect:
curl -i https://mgnet.cloud
HTTP/2 522
server: cloudflare
3 Likes

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