cancel
Showing results for 
Search instead for 
Did you mean: 

Occasional HTTP 522 with self-hosted server

FIXED
AlessioC
Newbie
Posts: 3
Thanks: 2
Registered: ‎17-03-2022

Occasional HTTP 522 with self-hosted server

Hello, at home I host a small webserver for private use on a Raspberry Pi. It serves a NodeJS-based application to play tabletop games. In the past I lived abroad (Bulgaria) and the same machine, with the same application, worked just fine under my previous ISP. However after I moved to the UK under PlusNet I started facing a number of HTTP 522 errors (connection timeout) when connecting to the server. The timeouts tend to go away after refreshing the page a couple of times, as the browser has time to build a local cache of the files it needs.

Now the server is proxied by Cloudflare, and I realize that a million things can be at fault for this problem, but I'm trying to troubleshoot exactly what it might be and I need to exclude any provider related issues. As far as I could gather:

  • It's not a CloudFlare cache problem (I tried disabling the cache).
  • It's not a CloudFlare firewall problem (I tried disabling the firewall).
  • It's not a CloudFlare proxy problem (I tried disabling the proxy and pass straight my IP).
    • In general CloudFlare seemed to route fine to my server when I was abroad.
  • It's not a DNS problem (I have a dynamic DNS service running and verified that my IP is correctly updated when it changes).
  • It's not a SafeGuard problem (I have SafeGuard disabled).
  • It's not a router firewall problem (I tried disabling it).
  • It's not a port forwarding problem (the application is reachable both outside and inside my home network).
  • It's not an application or machine-related problem (the application works perfectly fine in my local network. Also the same machine and application worked in the past under a different ISP).
  • It's not a browser problem (I tried with several different browsers: Edge, Chrome and Firefox. All face the 522 timeouts).

So I'm here asking, is there any chance there is something at the ISP level that is cutting my inbound connections short if they take too long? Or some specific configuration with inbound TCP keepalive messages?

7 REPLIES 7
AlessioC
Newbie
Posts: 3
Thanks: 2
Registered: ‎17-03-2022

Re: Occasional HTTP 522 with self-hosted server

I forgot to mention, the 522 errors are not on the page, they are on single resources (mostly javascript files) served by the application. So the page loads but malfunctions. As I said, this tends to solve itself by refreshing a couple of times, as scripts that have been downloaded stay in cache and the missing ones are fetched again.

dvorak
Moderator
Moderator
Posts: 29,473
Thanks: 6,623
Fixes: 1,482
Registered: ‎11-01-2008

Re: Occasional HTTP 522 with self-hosted server


Moderators Note


This topic has been moved from Fibre to Tech Help

Customer / Moderator
If it helped click the thumb
If it fixed it click 'This fixed my problem'
bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: Occasional HTTP 522 with self-hosted server


@AlessioC wrote:
  • It's not a CloudFlare cache problem (I tried disabling the cache).
  • It's not a CloudFlare firewall problem (I tried disabling the firewall).

For how long? Note that caching can occur outside of cloudflare too, e.g. on the server or client/browser.

I would associate a 552 error with a proxying service or similar, specifically Cloudflare. I would not expect you to see 522 errors when going direct to your IP address/server.

From here...

"Like many other error pages on the world wide web, the 522 message is one of the HTTP status messages: while the preceding '5' indicates a server error, the following '2' indicates that the server error has occurred in conjunction with Cloudflare."

Edit: It doesn't particularly help but FWIW I have a small number of servers hosted behind Cloudflare proxies that are routed using dynamic DNS and I've never encountered a 522 error.

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

Mook
Seasoned Champion
Posts: 1,266
Thanks: 870
Fixes: 9
Registered: ‎27-12-2019

Re: Occasional HTTP 522 with self-hosted server

@bobpullen  Could this be anything to do with Cloudflare's DDOS protection kicking in?

bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: Occasional HTTP 522 with self-hosted server

Fix

@AlessioC wrote:

I forgot to mention, the 522 errors are not on the page, they are on single resources (mostly javascript files) served by the application. So the page loads but malfunctions.


In the Network view of the browser debug console, there is probably a 'server' column that indicates the origin of the resources in question.

Maybe that offers some clues?

cloudflare_debug.jpg

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

bobpullen
Community Gaffer
Community Gaffer
Posts: 16,869
Thanks: 4,950
Fixes: 315
Registered: ‎04-04-2007

Re: Occasional HTTP 522 with self-hosted server


@Mook wrote:

@bobpullen  Could this be anything to do with Cloudflare's DDOS protection kicking in?


In that instance, I'd expect a 4xx error (if anything).

Bob Pullen
Plusnet Product Team
If I've been helpful then please give thanks ⤵

AlessioC
Newbie
Posts: 3
Thanks: 2
Registered: ‎17-03-2022

Re: Occasional HTTP 522 with self-hosted server

@bobpullen  I did as you suggested, and the content is coming from Cloudflare.

After a bit more playing around I think  the issue is entirely with Cloudflare. After realizing I could check the server I disabled Cloudflare's proxy, cleared the DNS cache and waited until I started getting responses directly from Nginx on my Raspberry. So fare I have reported 0 522 errors when the reply was coming from Nginx.

I think I was fooled by the DNS cache, I thought I was bypassing Cloudflare but it was still active. Thank you all for your assistance I will focus my investigation on Cloudflare.