Magento – Magento 2.3.3 – 502 Bad Gateway – Centos – Nginx

centoserrorinstallationmagento2.3.3nginx

After placed Magento 2.3.3 files to usr/share/nginx/html/magento & created database then run following,

php bin/magento setup:install --base-url=http://192.168.1.64/magento --db-host=localhost --db-name="magento" --db-user="root" --db-password="" --admin-firstname="abc" --admin-lastname="abc" --admin-email=abc@gmail.com --admin-user="magento" --admin-password="magento" --language="en_US" --currency="INR" --timezone="Asia/Kolkata" --use-rewrites="1"

and also edit etc/nginx/conf.d/magento.conf

upstream fastcgi_backend {
  server unix:/run/php-fpm/php-fpm.sock;
}

server {

  listen 8091;
  server_name http://192.168.1.64:8091/;
  set $MAGE_ROOT /usr/share/nginx/html/magento;
  include /usr/share/nginx/html/magento/nginx.conf.sample;
}

Screenshot : https://snipboard.io/K5t9Qm.jpg

How to solve 502 bad gateway error?

Note : <?php phpinfo(); ?> -> test.php inside /usr/share/nginx/html php info page return 502 bad gateway error.

Best Answer

you see this config part:

upstream fastcgi_backend {
  server unix:/run/php-fpm/php-fpm.sock;
}

this is where your php-fpm is listening. please check your php-fpm config, it must be the same socket path, with correct user read permissions. or change it to ip:port - 127.0.0.1:9000