Error 502 when traffic routed through the Cloudflare system

I am wondering when I am routed my traffic through Cloudflare system its showing port 80 is closed.

Can you rephrase your question?

I have create a new EC2 instance at AWS. It’s supposed to be a wordpress server & nginx is up & running. My domain is registered under Godaddy & after installing nginx the defult nagix welcome page is coming but the problem arise when I am change my nameserver to Cloudflare, now its showing Error 502 Bad gateway. I am very new so I think I may do some silly mistake. Can you please help on this matter.

Check if that helps

Tnx for sharing but if my server (AWS EC2) not configured properly then how its working when Godaddy nameserver is in use, that’s why im not able to understand as previously I assume like I do something wrong with the EC2 security group but I double check this.

EC2 has their own firewall (security groups) in front of their server instances Amazon EC2 security groups for Linux instances - Amazon Elastic Compute Cloud.

Did you make sure to whitelist http (port 80) and https (port 443) at EC2 Firewall level ? And also ensure your EC2 server is properly recording real visitor’s IP addresses ?

You may also need to whitelist Cloudflare IPs IP Ranges at EC2 firewall level

1 Like

my website url :

AWS security group setting inbound setting

So url domain works with Cloudflare disabled on non-https version of domain ?

curl check your url gives HTTP/1.1 521 Origin Down see troubleshooting steps at

have you verified that nginx sees real visitor ips and not Cloudflare’s ip ? check nginx logs for more clues as well

Tnx problem solve my nginx is not recording real visitor IP.

1 Like

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