Solution – 502 Bad Gateway on Homestead

September 20, 2020 by 2 Comments

Setting up homestead for windows is a big pain even for intermediate developers and very frustrating for new developers. Recently I run into this 502 Bad Gateway while setting up a new project on my new windows PC and after hours of digging and surfing the internet, I have two working solutions to this problem. If you’re facing the same error, then use any one of these solutions to resolve your problem.

Solution 502 Bad Gateway Error on Homestead

Solution One: Disable Xdebug

This is the first Solution I came across on StackOverflow. Yes and as always StackOverflow is the first place to reach for help, although I usually reach out to first before StackOverflow and then S-Techmax Forum.

Here is what to do to fix this error using this solution

  1. Boot up your VM using Vagrant up
  2. Vagrant ssh
  3. The run this code  sudo phpdismod xdebug.

See Also:

Solution – The guest machine entered an invalid state

Solution Two: Switch to using Apache

Another solution I tried and the problem was resolve is configuring my site on Homestead.Yaml to use Apache instead of Nginx.

  1. If your machine is running then run Vagrant Halt to power off
  2. Open the Homestead.yaml file and add this line of code to your site settings. type: “apache” so now it should look like this:
    - map: homestead.test
      to: /home/vagrant/learn/public
      type: "apache"

3. Run Vagrant up and everything should be fix.

Solution Three: Return to using PHP 7.2

Some folks on Github said this worked for them but on my machine, I had no luck with this solution. This should act as your last resort, that is if you dont want to disable xdebug and dont want to use apache.

Here is how your site configuration should look after making this change

    - map: example.test
      to: /home/vagrant/code/public
      php: "7.2"

Leave a Reply