Portal Home > Knowledgebase > Articles Database > nginx 502 and 504 errors


nginx 502 and 504 errors




Posted by Knocks, 08-29-2012, 03:14 AM
Hi guys, I run a busy phpBB forum on a dedicated server with nginx, APC, and memcached installed by my host. nginx constantly gives 502 bad gateway and 504 gateway timeout errors. The host tech people tried configuring it, but from what I understand they have no idea what they're doing because every tweak they make only results in more things breaking. Is it realistic to get this troubleshot and fixed via forums or should I hire a professional to configure it? How much would it cost me to get someone to configure nginx/apache, APC, and memcached for me? I really need everything to be bulletproof because the forum gets huge traffic, and the constant errors are getting my users down.

Posted by barbus, 08-29-2012, 06:27 AM
502 and 504 errors arise when the php doesn't have time give response to web-server. This may be because server has hight load, a large number of requests and etc. In any case server requires a full audit for determine cause of the problem.

Posted by TravisT-[SSS], 08-29-2012, 06:50 AM
What is the load on the server? And what are the config file settings? The setup is real easy.

Posted by Knocks, 08-29-2012, 06:54 AM
I really hope that's the case, because the entire IT staff of my host has not been able to find the magic combination for 2 months, even after their IT director interfered. Eventually they gave up and said that this was an advanced service and that I was on my own. I would have appreciated them telling me that two months ago. The funny thing is that without nginx at least the sites were working, although at peak times they were slow. But with it they are constantly broken. If you tell me which config files I need to look up, I will gladly post the details.

Posted by TravisT-[SSS], 08-29-2012, 06:56 AM
nginx.conf and the stats from top.

Posted by Knocks, 08-29-2012, 07:12 AM
What's the path? Sorry, I don't know my way around linux very well.

Posted by TravisT-[SSS], 08-29-2012, 07:15 AM
That would depend on how and where they set the paths up. You could try: Normally it's under /etc/nginx/nginx.conf Could also post contents of

Posted by Knocks, 08-29-2012, 07:22 AM
There's tons of different copies renamed at different times, but this is the current one. The nginx error log is 400MB so I'm not going to be posting that.

Posted by racknap1, 08-29-2012, 11:08 AM
Hi, Why don't you remove nginx and recompile Easy Apache from your WHM, then you can install nginx later.

Posted by Knocks, 08-29-2012, 11:54 PM
Apache alone is not cutting it for this traffic. nginx was working well when it worked, but now it's erroring out constantly after the admin at the host made some changes.

Posted by racknap1, 08-30-2012, 11:26 AM
Hi, If that be the case, please share your nginx logs :- To find the error log look in your main nginx config file. The error log should be defined there with :- The "error_log" directive. For example: error_log /var/log/nginx/error.log The "access_log" directive: access_log /var/log/nginx/access.log

Posted by Knocks, 08-30-2012, 01:56 PM
Hi, the error log is almost half a GB in size, not really fit for posting here, plus it has visitor IPs in it.

Posted by TravisT-[SSS], 08-30-2012, 03:45 PM
Could skim it and copy what is needed and then remove IPs. You mention he made changes, do you know what was changed? What is the load average and memory usage? You could try upping the timeout values for nginx and the PHP side of things.

Posted by Knocks, 08-30-2012, 06:25 PM
How much $$ should I expect to spend to have someone configure nginx, memcached, and APC so that my forum runs like a champ?

Posted by TravisT-[SSS], 08-30-2012, 09:19 PM
Depends on the business. To have it fully configured correctly probably from $$-$$$. Just ensure it is done manually and not from someone using a script.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
ionCube upgrade (Views: 2101)
Top Hosting Companies (Views: 596)