502 bad gateway running homestead laravel website

228 Views Asked by At

Whenever I try loading a project I get a 502 bad gateway error. I have tried refreshing the page I still get 502 error. what could be the issue?

This is a brand new fresh install of homestead with virtual box version 12.2.0

---
ip: "192.168.56.56"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
  - map: D:/git_projects/laravel/jonneyje
    to: /home/vagrant/jonneyje
  - map: D:/git_projects/laravel/brockphotography
    to: /home/vagrant/brockphotography
  - map: D:/git_projects/laravel/capstone
    to: /home/vagrant/capstone
  - map: D:/git_projects/laravel/abcbooks
    to: /home/vagrant/abcbooks
  - map: D:/git_projects/laravel/phpmyadmin
    to: /home/vagrant/phpmyadmin

sites:
  - map: jonneyje.test
    to: /home/vagrant/jonneyje/public
    php: "7.2"
  - map: brockphotography.test
    to: /home/vagrant/brockphotography/public
    php: "8.3.0"
  - map: capstone.test
    to: /home/vagrant/capstone/public
    php: "7.2"
  - map: abcbooks.test
    to: /home/vagrant/abcbooks/public
    php: "7.2"
  - map: phpmyadmin.test
    to: /home/vagrant/phpmyadmin

databases:
    - homestead

I have commented out the first top section of xdebug.ini zend_extension=xdebug.so and did absolutely nothing. I also tried changing the php project version to 7.2 and I get a compatability error when accessing my project.

1

There are 1 best solutions below

1
cengsemihsahin On

The temporary solution is to update your Homebrew PHP configuration.

Find the config file (it'll be named homebrew.mxcl.php.plist and it'll be in your Homebrew location, /usr/local/ or /etc/homebrew, under the folder Cellar/php/8.3.0, assuming you're on PHP 8.3.0).

Edit that file and add the following:

<key>EnvironmentVariables</key>
<dict>
    <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
    <string>YES</string>
</dict>

You'll add this directly under this line:

<key>RunAtLoad</key>
<true/>

Now run valet restart and try again.

If that doesn't fix it, let's do a little more cleanup.

  • Run brew services stop php to make sure you're not running PHP as your individual user (it should run as root)
  • Delete any homebrew.mxcl.php.plist files that are in ~/Library/LaunchAgents (this is the list of launch agents for your individual user)
  • Delete the php83 sock file (~/.config/valet/valet83.sock) and then valet install again

This answer was copied from here. I hope that will be useful. It solves similar questions for this problem in this platform. However, there was no answer to this. That's why I wanted to copy it here.