Troubleshooting Laravel Valet on macOS Sierra

News

September 22nd, 2016

mac-sierra-valet.jpg

macOS Sierra was released just a few days ago and everybody is starting to upgrade. Some users of Laravel Valet have reported some problems and Adam Wathan has put together a list of common problems and troubleshooting tips to help resolve issues he’s been seeing.

With his permission to post here is a list of things to look for:

All I see is “It works!”

Apache is running on port 80 and interfering with Valet.

  1. Stop Apache: sudo /usr/sbin/apachectl stop
  2. Restart Valet: valet restart

Valet randomly dies

You are probably still on Valet <= 1.1.19, it’s recommended to pin to ^1.1.22.

First, edit ~/.composer/composer.json to point to ^1.1.22 like this:

1```diff
2- "laravel/valet": "^1.1.19",
3+ "laravel/valet": "^1.1.22",
1
2Next, run `composer global update` and then restart Valet with it’s `valet restart` command.
3
4Every time I refresh I see a totally random file!
5-------------------------------------------------
6
7You are running Caddy 0.9.2, which has a known bug related to fastcgi connections.
8
9Edit your `~/.composer/composer.json` to point to `^1.1.22` like this:
1- "laravel/valet": "^1.1.19",
2+ "laravel/valet": "^1.1.22",
1
2Next, run `composer global update`, ensure you are now running Caddy 0.9.1 by running `~/.composer/vendor/laravel/valet/bin/caddy -version` and finally restart Valet `valet restart`
3
4I’m getting a 502 Bad Gateway error.
5------------------------------------
6
7Usually, this means something is messed up with PHP FPM. The first step is to confirm that FPM is *not* running:

ps aux | grep fpm

1
2You should see at least two processes there if PHP FPM is running (one is grep, ignore that one.) Chances are PHP FPM *is not* running.
3
4Next, check the PHP FPM error log to find out why it’s not running:

cat /usr/local/opt/php70/var/log/php-fpm.log

1
2Try to resolve any errors you see. Here’s a few common ones:
3
4- `/var/run/valet/fpm.socket` does not exist
5- Failed to open configuration file `/usr/local/etc/php/7.0/php-fpm.conf`
6
7Problem: /var/run/valet/fpm.socket does not exist!
8--------------------------------------------------
9
10If you see an error similar to:
11
12> Unable to bind listening socket for address ‘/var/run/valet/fpm.socket’: No such file or directory
13
14in the file `/usr/local/opt/php70/var/log/php-fpm.log`, you were probably running `dev-master` and have now switched back to tagged releases.
15
16Valet 1.1.22 attempts to automate fixing this issue by explicitly configuring where PHP FPM should listen.
17
18First make sure `~/.composer/composer.json` points to `^1.1.22`:
  • "laravel/valet": "^1.1.19",
  • "laravel/valet": "^1.1.22",
1
2Then run `composer global update` and finally `valet install`.
3
4Problem: php-fpm.conf is missing!
5---------------------------------
6
7Something went wrong when installing PHP through Homebrew. This seems to happen on fresh non-upgrade installations of macOS Sierra.
8
91. Uninstall PHP 7: `brew uninstall php70`
102. Reinstall PHP 7 from source: `brew install php70 --build-from-source`
113. Re-run `valet install`
12
13Where to Look for Valet Errors?
14-------------------------------
15
16If you are still running into problems, here’s a list of log files to check:
17
18**Caddy start log:**

/tmp/com.laravel.valetServer.err

1
2**PHP FPM error log:**

/usr/local/opt/php70/var/log/php-fpm.log

1
2**Caddy error log:**

~/.valet/Log/error.log

1
2Hopefully with this guide you will be able to pinpoint any errors you have and can fix them through either Brew or Composer.

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Laravel News Partners