Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running a php webapp and consistently get a: 502 bad gateway nginx error when attempting certain function within the site. Without trying to go into detail about what specific code may cause this (cause it could be anything) has anyone ever experienced this with a php/apache setup? Is it a code issue or an admin issue? I am using webfaction as my host.

Update: here is a log of the responses from my host:

This is often a symptom of hitting the maximum concurrent requests on the shared apache instance. If you would like, we can set you up on a private Apache+PHP instance, which should solve this issue for you. It will also have the added advantage of a performance increase, and the slight disadvantage of being counted towards your memory usage.


If you find it is happening consistently on a single function, then the concurrent requests issue is not the problem. It is most likely a time-out of the function you have narrowed it down to.

Your options in this case, are to either optimise the code for this function so it responds in a more timely fashion, or you could look into the possibility of increasing the time-out limit during that script's execution.

Does it seem like they are making any sense with this? I don't know what he means by a function timing out since I developed the app locally on a lamp stack with no time-out problems. Only once I uploaded the application to webfaction did I start getting this error.

share|improve this question
    
What kind of a screwed up config have they got, where running PHP under Apache gives nginx 502 errors? I think I'd be finding a hosting provider that had a bit more clue. –  womble Aug 24 '09 at 1:13
    
yea I honestly wouldn't have known that this is strange at all. Can anybody confirm that this is severely out of the ordinary? –  alb7 Aug 24 '09 at 1:40
    
As a hosting company sysadmin, I can confirm that if you are running PHP and Apache in any configuration I've heard of, having Nginx involved in the mix at all is severely out of the ordinary, and I would expect that a provider that did set things up that way would need to provide a significantly higher level of support to their customers due to the unique nature of the setup. –  womble Aug 24 '09 at 1:47
    
fair enough..thanks for your input –  alb7 Aug 24 '09 at 1:50
add comment

2 Answers 2

up vote 1 down vote accepted

Uhm... if it's a PHP/Apache setup, why are you getting an Nginx error message? On the assumption that you meant php/nginx, I'll continue...

Depending on how exactly your webhost has things setup, it could be one of a number of things. Most likely, one of the backend processes they're proxying to is giving 500 errors of it's own (that's pretty much what "Bad Gateway" means), so I'd start with looking into why your backends are sending back 5xx codes in response to requests. Look in the app error logs (to see what errors it is spawning) and nginx error logs (to see what URLs are causing the failures). Lodge a ticket with your hosting provider to get them to look at any logs you don't have access to yourself.

share|improve this answer
add comment

Its indeed a problem with the hosting provider! Open a ticket with them... Probably you in shared hosting e? :)

share|improve this answer
    
yes I am using shared hosting, I updated my question with their responses to my initial ticket –  alb7 Aug 24 '09 at 1:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.