Laravel 502 Bad Gateway when starting Laravel Valet — Simple solution

Panjeh
4 min readFeb 4, 2019

--

There are many solutions suggested here (link). There is another solution here (link).

The simple solution for solving every hard problem is to understand exactly what are you doing, it takes time but answers always!

The solution works for me is:

valet stop-->> you see: Valet services have been stopped.
valet uninstall
-->> you see: Valet has been uninstalled.

Then make sure the ~/.composer/vendor/bin directory is in your system's "PATH".

Then:

composer global require laravel/valet

You may want to restart your computer. Take a deep breath :)

brew update--> it takes time ......

Now is the turn to uninstall php and install a new version or switch between php versions.

Before you continue with the rest of this tutorial, I would like to introduce two packages for Laravel that I have recently developed: Laravel Pay Pocket, a modern multi-wallet package, and Laravel Failed Jobs, a UI for the Laravel Failed Jobs Table. I hope they may be of help to you.

https://github.com/HPWebdeveloper/laravel-pay-pocket
https://github.com/HPWebdeveloper/laravel-failed-jobs

Option A:
for uninstall you can follow this link. But it is not necessary to uninstall the php version you have now. Since you have another option B in laravel valet to switch between the php version. Although If you follow the above link to remove php entirely, there is no problem at all. Now I assume you want to uninstall php. In the uninstallation process you will reach the following command:

---- > be careful !brew cleanup

If you do brew cleanup you will LOSE your connection to database because of Link which the solution is this link.

Now you are going to install a new version of php. Be careful for the following command!:

brew install php

This will install/upgrade the php version to 7.3 which brings some bugs as Link1, Link2.

So you can install the lower versions of php by:

brew install php@7.2--> it takes time ......

Then:

brew services start php@7.2

Then:

valet install--> you see: Valet installed successfully!

It is done! and your laravel valet works fine.

Option B:

Instead of uninstall all php version entirely you can install the version you want and switch/link the valet to that version simply by:

valet use php@7.2

and then

valet installand orvalet restart

It’s done!

Thank you for reading! If you enjoyed this article:

Clap it ! Share it! Follow Me in Medium!

Also I’d like to hear your opinion on this article. If you have any doubt, question or suggestion please leave a comment below.

Have a very wonderful day!

Previous Stories You will Love:

--

--

Panjeh
Panjeh

Written by Panjeh

Posting about Python and Laravel

No responses yet