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 just don't know why i got a 502 error. Please help. you can visit here http://upliu.net/phpinfo.php phpinfo.php just has one line code: phpinfo(); but i got a 502 bad gateway error someone can help ? thanks Here are my configure files:

https://github.com/upliu/some-files

I use ubuntu server 12.04.3

nginx 1.4

php 5.5.7 with fpm

Hello, I am very cleared that php-fpm service is running and nginx just works fine. I write a test code which only contains one line 'echo "hello";', it can run perfectly, but after i added a new line 'phpinfo();' , i got a 502 bad gateway error , i don't know why, anyone can help me ?

share|improve this question

closed as unclear what you're asking by Wesley, Rex, mdpc, MadHatter, John Dec 18 '13 at 15:31

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

the 502 bad gateway error is not a php error, it is a HTTP (nginx) error that means nginx was not able to hand off connection to a listener. assuming you are running php as fpm, make sure the master phpfpm process is running, and make sure it is listening on the same tcp port nginx is passing connections to. check your proxy_pass nginx configuration and make sure your backend php-fpm process pool is running. remember to look thru nginx error logs, and once you get past the 502, and can see the phpinfo(), check your php logs for more issues.

share|improve this answer
    
thank you.i have restart the fpm many times and php-fpm has no error log. nginx's error log just said recv() failed (104: Connection reset by peer) while reading response header from upstream –  user1968677 Dec 18 '13 at 4:25
    
php-fpm does indeed have an error log, and it is configured via the "error_log" directive in php-fpm.conf. however, if you are still getting a 502, the connection is never making it to phpfpm, so there would be nothing there, until you fix the 502 issue....... double check the port you are passing the connection on... most likely you have a mismatch there –  nandoP Dec 18 '13 at 16:53

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