How to Fix the “502 Bad Gateway” Errors for MaxCDN hosted Images

In Web Hosting by Fathi Arfaoui0 CommentsLast Updated: February 20th, 2017

Last time, I got surprising error messages with all the site’s images. I was hosting the static assets, including media with MaxCDN, and they worked well. However, sometimes when you change something including the server or the IP, your web hosting may blacklist the MaxCDN network from accessing your images and make a copy of them.

502 bad gateway Nginx

 

Please note that the error is not related to Nginx, it can appear with Lightspeed, Apache and other web servers.

502 Bad Gateway

What caused the “502 Bad Gateway”?

The reason is a firewall that missed the list of IP addresses of any CDN or files sharing services. That’s the real issues, but there are always solutions for any problem.

If you got 502 bad gateway image errors with WordPress, Drupal or any other site software and you use MaxCDN, then, you need to modify the firewall settings or ask your web hosting provider to do that for you.

MaxCDN is one of the largest CDN networks in the world, they have thousands of servers across different countries. Unfortunately, when they add new servers, the IP address is not added to hosting services. As a result, the Web Firewall won’t be able to know that the new IP is from a CDN. When the server request the file it gets nothing as a blocked access.

I recommend contacting your company and ask them to whitelist the MaxCDN IP addresses listed below:
108.161.176.0/20
94.46.144.0/20
146.88.128.0/20
198.232.124.0/22
23.111.8.0/22
217.22.28.0/22
64.125.76.64/27
64.125.76.96/27
64.125.78.96/27
64.125.78.192/27
64.125.78.224/27
64.125.102.32/27
64.125.102.64/27
64.125.102.96/27
94.31.27.64/27
94.31.33.128/27
94.31.33.160/27
94.31.33.192/27
94.31.56.160/27
177.54.148.0/24
185.18.207.64/26
50.31.249.224/27
50.31.251.32/28
119.81.42.192/27
119.81.104.96/28
119.81.67.8/29
119.81.0.104/30
119.81.1.144/30
27.50.77.226/32
27.50.79.130/32
119.81.131.130/32
119.81.131.131/32
216.12.211.59/32
216.12.211.60/32
37.58.110.67/32
37.58.110.68/32
158.85.206.228/32
158.85.206.231/32
174.36.204.195/32
174.36.204.196/32
151.139.0.0/19
94.46.144.0/21
103.66.28.0/22
103.228.104.0/22

If this list is not working, then a new IP address was added and you can find all their IP blocks updated.

How to investigate your images and why they are not showing in WordPress or any other software? All you need is to Traceroote your image requests. You can Traceroote any address on Mac or Windows and that way, you can get detailed information about the error.

On Mac OS, for example, you can run a Traceroote by launching Network Utility. But first, click the search icon spotlight on your Mac, then, type Network Utility and click on it. Next, choose the Traceroote tab. Enter the exact URL of any of your images that are not showing correctly in the browser, and click the Scan button.

When the scan is complete, look for error details, and if you couldn’t find what all that code means, copy all the code and send it to your hosting’s technical customer support. That way, you gave them more details about the issue and they have all the Traceroote.

images traceroot

For Windows computers, follow this tutorial by Microsoft. It shows what you need as steps.

If you still unable to solve the problem, then there is something strange with your images or media files. The best thing you can do is scan your files for malware and codes. It’s right that the 502 bad gateway errors are related to server connection. But sometimes, plugins can come with wrong configurations and users can modify the settings by mistake, especially with caching plugins like W3 Total Cache, Super Cache, WP Rocket, and others.

In this case, try to disable the caching plugin and clear your browser cache, then check your images again. If it didn’t work, disable all your WordPress plugins at once or one by one, until you find the one that caused the problem.

I hope this fixed your problem of images on your blog or website. If you’ve fixed the issue with other ways, let me know and I’ll add your solution.

Fathi Arfaoui: A Physicist, Blogger, and the founder and owner of Trustiko.com. He shares Business, Blogging, WordPress, Web Safety, and Blogging tips to build better websites and blogs. Also, he shares online marketing strategies and recommendations.

Leave a Comment