Error 502 Bad gateway - random and only on certain subdomains


#1

Big trouble: i’ve got random 502 Bad Gateway error on some subdomains of my service.

Maybe someone else has had my same problem and he’s fixed it!

Esample.:
http://subdomain1.mydomain.com
http://subdomain2.mydomain.com
(the url are fakes beacuse in the moment i’m writing the problem doesn’t exists! It’s random!)

Both go to my unique server and both use the same code to run.

No errors on any of server’s log file.

Both have a couple of CNAME record on my Cloudflare’s DNS setting (example)

subdomain1.mydomain.com is an alias of www.mydomain.com
www.subdomain1.mydomain.com is an alias of www.mydomain.com

THE PROBLEM:
The first one URL returns some of 502 errors trying to load some resources files (js, html, php) form my server.
The second one URL loads the same files with no problem

INFO 1:
Both return the same Cloudflare IP using ping

INFO 2:
I tried to call the url with 502’s problem using www prefix: http://www.subdomain1.mydomain.com

http://subdomain1.mydomain.com --------------> 502 BAD GATEWAY
http://www.subdomain1.mydomain.com --------> WORKS

INFO 3:
Tried to turn off the orange cloud icon on CNAME record on the url: http://subdomain1.mydomain.com

http://subdomain1.mydomain.com -> with GRAY CLOUD ICON -> WORKS!!!
After that back again to ORANGE CLOUD ICON but now… IT WORKS!

I think it’s a CloudFlare problem…

Hope someone can help me!

PS: The problem, normally, seems to solve itself in a random time range between 0-30 minutes. Anyway it’s a problem.


#2

Domain?


#3

domain: https://www.fmsrevo.it


#4

Alright, DNS looks alright. You mentioned two host entries, but then only referred to the first. So there is no problem with “subdomain2” or why did you mention it?

Can you post the actual host in question and could you find any way to reproduce it? For the record, it does not involve HTTPS, does it?


#5

Thanks for reply,

So there is no problem with “subdomain2” ?

You’re right, no problem with “subomain2” (same server, same code, same files required)

Can you post the actual host in question and could you find any way to reproduce it?

Unfortunally no, i can’t reproduce it. That’s the big problem, it seems to be a totally random behavior.

Can you post the actual host in question and could you find any way to reproduce it? For the record, it does not involve HTTPS, does it?

You’re right again, subdomains are not HTTPS.


#6

How did you check the outages? Did you always run a check consecutively for both addresses (with and without www)?


#7

Did you always run a check consecutively for both addresses (with and without www)?

Yes, after the first time i’ve checked that with www prefix, the url was fine, i tried again for a couple of time with and without the prefix to be sure about it.

So, confirmed: works with www, errors 502 without.

Then i tried turning off the cloud icon, from my cloudlare’s dns settings, i’ve wait for a couple of minutes (checked via ping) for the IP changing… and when the ip changed from Cloudflare’s IP to my host IP… the url is returned to work without 502 errors even without WWW prefix.


#8

Well, of course I cant rule out an issue with Cloudflare but based on experience I’d dare to say it is unlikely. Can you post the full URL here?


#9

Well, of course I cant rule out an issue with Cloudflare but based on experience I’d dare to say it is unlikely.

Well… i’m working with same host, server, subdmains and code from 3 years.

Never had problems like this until i’ve started using Cloudflare last june.

It’s very strange that’s a coincidence.

Really… i’ve got free plan… maybe something linked to that?


#10

No.

Without further details it is impossible to say anything more though.


#11

I can’t reproduce it, there is nothing on my logs so… only CloudFlare can have more details, that’s right (i’ve got the url and the date of the last 502 error maybe there is something in their logs)?


#12

Then I would check for that.

Again, if you can the post the host in question it might be possible to have a more indepth look.


#13

Again, if you can the post the host in question it might be possible to have a more indepth look.

Sorry for that, i was sure to have write it before…

My host is ARUBA.
I can’t write here the full url for my users’s privacy (can i pass it to you via a private message?)
The last problem is happened 6 - 6 1/2 hours ago (between 08.00 : 08.50 AM - ITALY)


#15

Replied


#16

Slight change in circumstances :slight_smile:

It is not like www.[third-level-domain].SLD.TLD versus [third-level-domain].SLD.TLD but its about different third level domains. Probably shouldnt change that much but still worth noting. The hosts are all behind Cloudflare.

Question @bjgiu, are you absolutely sure the hosts in question really point to the same IP? Can you double check?

Also, did you take a look at the log file(s) if there are any entries for the time when there was the issue this morning?


#17

Sorry, i don’t understand…

It is not like www.[third-level-domain].SLD.TLD versus [third-level-domain].SLD.TLD but its about different third level domains.

Why do you think in that way?

I mean, i’m talking about the same third level domanis.

. subdomain1 with and without WWW has different behaviour. (502 without WWW - FINE with WWW)
. subodmain2 with and without WWW has same behaviour (FINE with and without)

So, just talking about the URL with erros (same subdomain)
http://subdomain1.mydomain.com --------------> 502 BAD GATEWAY
http://www.subdomain1.mydomain.com --------> WORKS

Maybe there is something i missed?

are you absolutely sure the hosts in question really point to the same IP? Can you double check?

Sure,. I’ve got only one public IP.


#18

You sent me three hostnames and said two were fine and one of them had the issue. There was no www involved or did I understand you wrong and none of the hosts you sent me has the issue and only if you try to access the one you pointed out using www it will exhibit the problem?


#19

You sent me three hostnames and said two were fine and one of them had the issue. There was no www involved or did I understand you wrong and none of the hosts you sent me has the issue and only if you try to access the one you pointed out using www it will exhibit the problem?

Ok, i sent you three hostnames without WWW:

  • two of them had the issue.
  • one of them no.

The same three hostnames with WWW, all of them they had NO PROBLEM.


#20

Correct, I just got it the other way round. So the differences are not between the different subdomains, but within them. With www is always works, without it show intermittent issues.


#21

Correct, I just got it the other way round. So the differences are not between the different subdomains, but within them. With www is always works, without it show intermittent issues.

Yes, today, this was the behaviour.