Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

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 the crazy ones running beta software.

EDIT on 2016-09-21: alternatively, you could use the dev-sierra branch to get a working version of Valet on macOS Sierra.

EDIT on 2016-09-24: Adam has published a list of common problems and solutions for running Valet on Sierra.

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band.
  • Mark van Eijk

    I’m totally the same on this beta thing 😉 and had also this issue with Valet! Restarted it today a hundred times I think.. hope this will fix it!

  • yuters

    Beware that if you’re requiring dev-master of valet you might encounter a bug when serving static files. More info here:

    But yeah I’m glad there is a workaround for the crash every couple of minutes. It was starting to drive me crazy!

  • Excellent, I’ve been lookinf for just this fix.

    On a side note, you can also install caddy via brew and symlink it and keep it up to date that way.

    brew install caddy
    rm ~/.composer/vendor/laravel/valet/bin/caddy
    cd ~/.composer/vendor/laravel/valet/bin
    ln -s /usr/local/bin/caddy

  • Hector Mendoza

    Nice! This seems like a permanent solution. Up until now I was running the command `sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist`, every time I logged in to my computer and Valet was working again. Found that solution on a Docker blog post, which was broken as well on Sierra. Thanks for the info!

  • Does this work on the GM? having issues..