Fixing Laravel Valet on macOS Sierra

I’m one of those people who runs beta software. A short time after the keynote is finished I’ll update (or wreck) my phone with the beta version of iOS. My Mac generally gets the beta treatment not much later. Of course there are some risks involved. There’s no guarantee that your applications will still work. Though your mileage may vary, it’s my experience however that those betas are pretty stable.

With macOS Sierra there was one piece of software that didn’t work properly: Laravel Valet. For some obscure reason Valet just stopped working after a couple minutes. The requests just hang. After some time an ERR_CONNECTION_REFUSED was displayed in Chrome. After running valet restart it ran fine for some more minutes. After poking around in the configuration of caddy, the webserver that powers Valet, and the php.ini file I found no solution. A complete reinstall of Laravel Valet did not solve the issue. I learned to live with the problem, regularly running valet restart. I even set up an alias for it.

But luckily Bryce Adams found the solution (Martin Bastien notified me about it). It’s very simple: you just have to update the caddy server to the latest version manually. Here are the steps involved:

  1. Download caddy_darwin_amd64.zip from Caddy’s releases page on GitHub.
  2. Extract the files and rename the main executable caddy_darwin_amd64.zip to caddy
  3. Copy it over and replace the old caddy file in this directory: ~/.composer/vendor/laravel/valet/bin/
  4. Run valet restart
  5. Profit!

I hope this post can help all those crazy ones running beta software.