New Laravel (Homestead) installation: 502 Bad Gateway - *Refresh* - the website is displayed correctly New Laravel (Homestead) installation: 502 Bad Gateway - *Refresh* - the website is displayed correctly nginx nginx

New Laravel (Homestead) installation: 502 Bad Gateway - *Refresh* - the website is displayed correctly


Aaron Belz exact steps didn't work for me, but following the link did.

It was xdebug, unfortunately for me too.

sudo vim /etc/php/7.3/mods-available/xdebug.ini

And prefixed all the lines with ; - then followed Aaron's instructions:

sudo service nginx restartsudo service php7.3-fpm restart

And it worked. Now I'm worried if I need xdebug for anything - I'm not gonna be able to use it until I find the fix. Ah well, cross that bridge when I get there :D

I will also note I'm on Windows, and I know Vagrant sometimes has problems with that so maybe that has something to do with it.


Try to disable XDebug. This worked for me but feels sorta hacky. I'll update this if I come up with a better solution.

There should already be an xoff alias in "aliases". So run xoff in your vagrant box, then restart NGINX and PHP7.3-FPM. (If you don't have or want the alias use sudo phpdismod -s cli xdebug in-place of "xoff" where I mention it)

Here's the steps (remember this is done through the homestead box):

  1. xoff
  2. sudo service nginx restart
  3. sudo service php7.3-fpm restart
  4. Try again after a hard reload and pray!

Again I'm not satisfied with this solution yet. However here's how to disable XDbug in a more proper way although I have not tested yet, so let me know how it goes if you try.

Hope this works for you, I spent all night trying to figure this one out lol. As such its 5 am and I'm not even sure if I'm speaking English anymore.


Just the same issue (502 error on nginx). I know its an old question, but happened recently again because there is a problem in the release branch of laravel\homestead where this change is not included yet:https://github.com/laravel/homestead/pull/1691/commits/78a573f62a9160e8d9c302667649089cf8a2435c

So in my case, running php 7.4 this two lines fixed the problem:

sudo systemctl enable php7.4-fpmsudo service php7.4-fpm restart