I have installed magento 2.4.2 and installation is done but when tried to access through url it shows 502 bad gateway error

  • 1
    It is related to your web server configuration. It is hard to answer without knowing your server configuration. developer.mozilla.org/en-US/docs/Web/HTTP/Status/502 Jul 15, 2021 at 10:43
  • Is this an upgrade or new install? There could be some issues with an upgrade because they moved index.php into /pub folder. Check nginx.conf.sample and compare it with your nginx.conf for changes. Jul 15, 2021 at 10:59
  • new installation
    – Asssd
    Jul 15, 2021 at 11:06

2 Answers 2


502 Bad Gateway its a webserver error, so something are going wrong here. We need to know about its NGINX or Apache webserver you are running you Magento on.

In my case I have created a Docker setup to have all the pre-config for me when I developer Magento code.

I know there are a huge NGINX config file you need to take care of if you are running on NGINX webserver, if you are running Apache I can't help here sorry.

The next step I see when you have running the upgrade cli command, you need to get the right access to your project folder in my case becures its local I run it, I just give it chmod -R 777 project/ if you are running on production 777 its not recommended.

But again when you hit 502 Bad Gateway there can be a lot of different errors here on you webserver access log.

Remember Magento required (PHP, MySQL and Elastic) to get up and running.


Can you try changing your document root to "pub" folder? From the newer version of Magento, you need to keep your document root to pub folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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