Website is not up due to HTTP Error 520

I recently transferred my domain to cloudflare, and that went smoothly. I transitioned the HTML and CSS to Wordpress to be in cooperation with a tutorial I was following to get Cloudflare set up. The main idea is so I no longer have to pay for a more pricy web hosting server. Therefore, I am now using raspberry pi for my web server. I tried setting up a cloudflare tunnel on the raspberry pi. I utilized this tutorial: Setting up a Cloudflare Tunnel on the Raspberry Pi - Pi My Life Up.

When I attempt to access my site, I get a 520 error.

In Cloudflare, it shows that my domain is active, under the DNS section

In my DNS management for the website, I have three DNS records. Two are A type (One is * and the other is www). The other is a CNAME and it is [I PLACE THE TUNNELID HERE]

For the config.yml file, I used the following but swapped the items that are shown in the brackets below:

tunnel: [TUNNELNAME]
credentials-file: /home/[USERNAME]/.cloudflared/[UUID].json

    - hostname: [HOSTNAME]
      service: https://localhost:8080
    - service: http_status:404

I then ran ‘cloudflared tunnel --config ~/.cloudflared/config.yml run’.

It ran but my site is still showing http 520 error.

Any help does help. Thank you!

It’s not impossible, but 8080 is a rather unusual port for HTTPS. Is your server actually listening on port 8080 via HTTPS or only HTTP?

Are these names supposed to not go through the tunnel?

I assume that is the name your are trying to open?

1 Like

Thanks for your help.

I just noticed your response. In the interim, I had changed the port to 80.

I did this because in terminal I ran sudo netstat -plnt and noticed that 619/apache2 is listening on port 80. I also noticed 17493/cloudflared is listening on port 38655.

Regarding your second question, I still have that CNAME in the DNS records. I also now have another CNAME and that is just my domain (for anonymity:

I am trying to open up the domain to the public.

Update: My website generally works locally, but it is not working when I tried to access it outside of my personal wifi network.

Can you share your Nginx or Apache config that shows on what port your application is listening?

1 Like

Sure. I ran the following two commands:

> cd /etc/apache2
> grep -r 'Listen' /etc/apache2

Here was the result:
/etc/apache2/ports.conf:Listen 80
/etc/apache2/ports.conf: Listen 443
/etc/apache2/ports.conf: Listen 443

Okay so it looks like I figured it out. I changed the iPv4 address for both of the two Type A DNS records, respectively, to the same IPv4 address to the web hosting IP used by my previous web host server. For further clarity, if you look back at my initial inquiry, prior to my transfer of my domain to cloudflare, I used a separate site for my web hosting.

Re-opening this issue. The IPv4 address that was used has been suspended now, as this was from the old web hosting provider, which I no longer pay for. So I think the current issue is gathering what the public ipv4 address is for my domain.

Now, in order to attain the public ipv4 address for my domain, I utilized dig +short This displayed two ipv4 addresses - however both of these did not work when I tried them individually for both of the A types.

You don’t need an IP address if you are using Cloudflared. The DNS record will be created automatically.

Your Apache doesn’t seem to be listening on 8080, the port you specified in your Cloudflared config.

Could you show your site config? It should be in /etc/apache2/sites-available.

1 Like

I did a re-work. I removed both of the A types. I now am down to two CNAMEs.

#1: Type: CNAME Name: www Content: {TUNNELID}
#2: Type: CNAME Name: Content: {TUNNELID}

Next, I decided to switch to nginx, in order to follow a different tutorial. I stopped and disabled my apache2 server, as it was listening to port 80. I also discovered a lighttpd server listening to port 80 - I removed and disabled that as well. Now, my nginx server is installed and listening on port 80 via the raspberry pi (note: the other two server were on the raspberry pi).

Almost there: My site is running if I do not include www in the beginning of the site name. Quite strange. Here is a look at my /etc/nginx/sites-available/default file:

# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

# Default server configuration
server {
        listen 80 default_server;
        listen [::]:80 default_server;

Then, for simplicity’s sake, I would recommend that you just create a Redirect Rule in Cloudflare that redirects the www version to the apex.


Right so my first CNAME was just:

Type: [CNAME] Name: www Content: {TUNNELID}

I just modified the Content to be my domain, but it still not working.

You can create a redirect by creating a Redirect Rule. Changing the CNAME record does not help you with a redirect.

Create a redirect rule like this:

If hostname equals
static redirect

I tried doing the redirect through the nginx server, but it was not working after testing. I made the redirect via Cloudflare’s page rules utilizing a forward url with a status code 301. The redirect is from to The redirect works! I wonder in the future what would resolve the www, but nonetheless the site is working. Thank you for your help - very much appreciated! :slight_smile:

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