Magento – How to solve 502 Bad Gateway with SOAP calls on nginx

nginxserver-setupsoapweb services

A Magento store, running on AWS using nginx for a webserver, has been working in production for a number of weeks. We have an integration with a shipping provider who uses SOAP to do your standard fulfillment integration "stuff". This has been working also for two weeks.

Yesterday, our client moved the site from AWS to Rackspace. This was a full move of the site, including the database. Everything seems to be working via web browser (able to browse, checkout, log in to backend, etc). However, now when SOAP calls are made to the server a 502 Bad Gateway error happens. The exact symptoms are as follows:

  1. Regardless of v1 or v2
  2. When making a login request $client->login('user','blah'); the service takes a very long time to respond
  3. Eventually (say, 15-30 seconds?) there is a 502 Bad Gateway request.

I've looked at the logs, and see a number of things:

First, from nginx access logs:

<ip omitted> - - [20/May/2014:16:38:46 +0000] "POST /index.php/api/soap/index/ HTTP/1.1" 502 166 "-" "PHP-SOAP/5.4.10" "-"

Then, from the nginx error logs:

2014/05/20 17:04:44 [error] 3297#0: *17 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: <ip omitted>, server: store.mydomain.com, request: "POST /index.php/api/index/index/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "store.mydomain.com"

And finally, from the fastcgi log:

[20-May-2014 17:02:27] WARNING: [pool mydomain.com] child 23853 exited on signal 11 (SIGSEGV - core dumped) after 13474.896102 seconds from start
[20-May-2014 17:02:27] NOTICE: [pool mydomain.com] child 3321 started
[20-May-2014 17:03:58] WARNING: [pool mydomain.com] child 23854 exited on signal 11 (SIGSEGV - core dumped) after 13565.467026 seconds from start
[20-May-2014 17:03:58] NOTICE: [pool mydomain.com] child 3327 started
[20-May-2014 17:04:44] WARNING: [pool mydomain.com] child 23856 exited on signal 11 (SIGSEGV - core dumped) after 13611.667319 seconds from start

I've done a fair amount of googling, but haven't found anything concrete. I'm not enough of a nginx/php/fastcgi/whatever guy to be able to look at this logs and say "oh, that's it!", but I'm hoping somebody else might be able to.

Note that I can login to the admin fine, and again in general the site works as expected.

Thanks for any help!

Best Answer

Well, in this case the situation was apparently one of name resolution. Apparently the server was unable to resolve "itself." Sadly, I didn't find this result when searching, but Alan Storm (the god of Magento himself) mentioned this as a problem.

So, in short, read that post for more info, but we were able to fix this issue by adding a host entry on the server. After this point, things were working once again.

<servers ip address> storedomainname.com