0

I'm getting a 502 Bad Gateway error for wp-admin/admin-ajax.php -- this is a WP site, hosted on WebFaction, which is using nginx.

Where it most obviously crops up is when adding a new post or page, clicking on "Insert Media", nothing in the library shows up. Inspector console is filled with these:

POST http://lightuphope.org/wp-admin/admin-ajax.php 502 (Bad Gateway) load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-u…:5
send load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-u…:5
x.extend.ajax load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,jquery-ui-core,jquery-ui-widget,jquery-u…:5
i load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,schedule,wp-ajax-response,autosave,sug…:48
(anonymous function)
  • Check your logs. Do you see these "Bad Gateway" statuses everytime something uses admin-ajax.php? – s_ha_dum Feb 26 '14 at 1:12
  • I don't know if it's EVERY time, but the error log is packed full of these errors. – madlabmg Feb 26 '14 at 18:23
  • Loading that file directly in a browser returns a 200 status not a 502 one. Maybe there is a loopback issue. If you have ssh access on your server try curl http://lightuphope.org/wp-admin/admin-ajax.php and see what you get. – s_ha_dum Feb 26 '14 at 19:06
  • when I do 'curl', it returns "0" -- which is the same as running it directly in the browser, which as I understand is a successful load. – madlabmg Feb 26 '14 at 19:35
1

I had similar problem on wordpress site. add these lines inside http block of /etc/nginx/nginx.conf file.

fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;

If it still not working also add this line

 client_max_body_size 50M;
0

What Does 502 Bad Gateway Mean?#

A 502 Bad Gateway indicates that the edge server (server acting as a proxy) was not able to get a valid or any response from the origin server (also called upstream server). This can occur for a few reasons, which we’ll discuss in the section below. If one of KeyCDN’s edge servers receive a 502 Bad Gateway response from your origin server, KeyCDN will return a 500 Origin Not Reachable page. To get a better understanding on how KeyCDN handles certain error codes, check out our CDN Error Codes page.

How to Solve 502 Errors - for Web Developers#

As a web developer or owner of the website, there are a few reasons why you may be experiencing a 502 Bad Gateway error on your origin server. Therefore, you may need to try various methods to resolve the issue. Reference the list of suggestions below:

Check if your FQDN (fully qualified domain name) is resolving correctly by using our DNS test tool. Verify if your server is reachable by using a ping test or trace-route. Check your firewall logs if you are seeing unusual drops. If you’re a Cloudflare user, try disabling it as once you’ve reached a certain limit Cloudflare will return a 502 Bad Gateway error to your visitors.

How to Solve 502 Errors - for Visitors#

If you’re a website visitor and experience a 502 Bad Gateway error then there is also a few things you can try to resolve it. Although the primary issue will almost always be the responsibility of the web developer, visitors can try the following:

Perform a hard-refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R. Clear your browser cache and delete cookies. Your browser may be holding on to certain files that were saved once you visited the website with a 502 error. Restart your computer/networking equipment Change your DNS servers. If you’ve never changed them in the past you likely still have the default servers assigned to you by your ISP, try using open DNS servers such as Google's Public DNS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.