Discover Centmin Mod today
Register Now

Nginx PHP-FPM Getting 502 Bad gateway error Nginx

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pheonis, Apr 1, 2019.

  1. pheonis

    pheonis Member

    62
    3
    8
    Dec 21, 2018
    Ratings:
    +4
    Local Time:
    6:55 PM
    Hi There,
    i am currently setting a new website on a new server with centminmod, after setup i put my wp files using ftp. Now i am getting 502 Bad gateway error nginx.


    Code:
      tail -10 /usr/local/nginx/logs/error.log
    
    Shows This :
    Code:
    2019/04/01 03:22:03 [alert] 844#844: setpriority(-10) failed (13: Permission denied)
    Code:
    tail -10 /home/nginx/domains/domainname.com/log/access.log


    showed this :

    Code:
    117.227.60.99 - - [01/Apr/2019:10:41:26 +0000] "GET / HTTP/2.0" 502 552 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Redmi 4A Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.68 Mobile Safari/537.36"
    117.227.60.99 - - [01/Apr/2019:10:41:33 +0000] "GET / HTTP/2.0" 502 552 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Redmi 4A Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.68 Mobile Safari/537.36"
    

    I am unable to resolve the issue. Can you shed some light @eva2000 into the issue.

    Thank you
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,113
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    11:25 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Need all info below

    Please fill in any relevant information that applies to you:
    • CentOS Version: i.e. CentOS 6 32bit or 64bit / CentOS 7 64bit ?
    • Centmin Mod Version Installed: i.e. 123.08stable or 123.09beta01
    • Nginx Version Installed: i.e. 1.15.3
    • PHP Version Installed: i.e. 5.6.37, 7.0.31, 7.1.21, 7.2.9
    • MariaDB MySQL Version Installed: i.e. 10.0.x or 10.1.xx or 10.2.xx
    • When was last time updated Centmin Mod code base ? : i.e. run centmin.sh menu option 23 submenu option 2 or cmupdate command
    • Persistent Config: Do you have any persistent config file options set in /etc/centminmod/custom_config.inc ? You can check via this command:
      Code (Text):
      cat /etc/centminmod/custom_config.inc
      

      Post output in CODE tags.

    Also Getting Started Guide step 2 for after you create nginx vhost and if you uploaded files via root user sftp need to chown and chmod permissions to nginx user/group.

    Also if you're using OpenVZ 7 based CentOS 7 you may have run into issue @jcat had https://community.centminmod.com/threads/php-fpm-fails-to-start-on-openvz7.17045/. So if you are using OpenVZ 7 based VPS with CentOS 7 you may need to edit /etc/systemd/system/php-fpm.service.d/limit.conf to remove the line
    Code (Text):
    Nice=-10

    then restart php-fpm service
    Code (Text):
    systemctl daemon-reload
    systemctl restart php-fpm
    
     
  3. fillermark

    fillermark New Member

    2
    0
    1
    Dec 10, 2019
    Ratings:
    +0
    Local Time:
    6:55 PM
    1.3
    MYSql
    Bad gateway refers to http error 502 which is mean that a server which is try to fulfill the client request received an invalid response from upstream server. It is often a network error between servers on the internet, meaning the problem wouldn't be with your computer or internet connection. Empty or incomplete headers or response body typically caused by broken connections or server side crash can cause 502 errors if accessed via a gateway or proxy. Since it's just a generic error, it doesn't actually tell you the website's exact issue.

    How to Solve 502 Errors
    • Perform a hard-refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R.
    • Clear your browser cache and delete cookies. Your browser may be holding on to certain files that were saved once you visited the website with a 502 error.
    • Change your DNS servers. If you’ve never changed them in the past you likely still have the default servers assigned to you by your ISP, try using open DNS servers such as Google's Public DNS.
    • Finally, restart your computer/networking equipment. Some temporary issues with your computer and how it's connecting to your network could be causing 502 errors, especially if you're seeing the error on more than one website. In these cases, a restart would help.
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,113
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    11:25 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  5. jackryan0307

    jackryan0307 New Member

    8
    1
    3
    Jan 31, 2020
    Ratings:
    +1
    Local Time:
    6:55 PM
    You can fix 502 bad gateway by doing the following methods:

    1. Refresh your browser and reopen it: First, you need to close your current browser and hold up a couple of moments and reopen it. It is because Sometimes your browser may stop responding due to accessing the heavy traffic of data at the same time or maybe an error page is inserted in between the pages which are loading. Even you try on another browser as well.
    2. Reset Internet configuration: You need to restart your internet modem. to do this, Unplug your internet modem and hold up for 5 seconds, after it completely turns off, Plugs it again and Wait for your computer to establish a connection again.
    3. Disable CDN temporarily: The Content Delivery Network or commonly known as CDN improves the loading speed of a website but it can generate error 502 as well due to the firewalls. To overcome this issue, you can disable the CDN temporarily.