Fixing bad gateway issue 502

July 4, 2017 432 views
Server Optimization Ubuntu

Hi everyone,

From time to time my website is getting error 502 bad gateway or just simply doesent loading up. When I'm looking at the graphs of CPU usage I've realized that when I want to edit some posts on wordpress the CPU usage increasing to high levels like 90%.

What I'm supposed to do, restart the droplet or resize the plan? When I do this everything will be good?

2 Answers

Hi @brzezickiandrzej

What web server are you using, Apache or Nginx? Which version?
And which version of PHP?
Are you running Ubuntu 14.04 or a different version?

When you have the problem with high CPU, which process is eating everything?
You can run the command top to see processes and amount of CPU+RAM they eat.

Usually the problem is rooted in a bad plugin in WordPress, since the way it's crashing.
How big is your droplet?

I'm using Nginx 1.1.0.5, Ubuntu 14.04.

How I am supposed to check which plugin is causing the problem?
Screenshot of console

  • @brzezickiandrzej

    Are you only running WordPress on the server?

    I would recommend that you move away from HHVM, since PHP 7 has become even faster.
    And since you're running a fairly old version of everything, I would guess HHVM is also old, which means it's not very stable - and might actually be the reason for the crashes (well, it's guaranteed HHVM that is crashing, but the reason behind is unknown).

    When it crashes, then please include the last 30 lines from the error log - run this:

    tail -30 /var/log/nginx/error.log
    

    Edit: The screenshot didn't show high CPU - actually about 99% idle.

Have another answer? Share your knowledge.