Create a gist now

Instantly share code, notes, and snippets.

Embed
Troubleshooting Valet on macOS Sierra

Troubleshooting Valet on Sierra

Common Problems

Problem: I just see "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

Problem: Valet randomly dies once in a while.

You are probably still on Valet <= 1.1.19, we recommend pinning to ^1.1.22.

  1. Edit ~/.composer/composer.json to point to ^1.1.22:

    - "laravel/valet": "^1.1.19",
    + "laravel/valet": "^1.1.22",
  2. Run composer global update

  3. Restart Valet: valet restart

Problem: Every time I refresh I see a totally random file!

You are running Caddy 0.9.2, which has a known bug related to fastcgi connections.

  1. Edit ~/.composer/composer.json to point to ^1.1.22:

    - "laravel/valet": "^1.1.19",
    + "laravel/valet": "^1.1.22",
  2. Run composer global update

  3. Ensure you are now running Caddy 0.9.1: ~/.composer/vendor/laravel/valet/bin/caddy -version

  4. Restart Valet: valet restart

Problem: I'm getting a 502 Bad Gateway error.

Usually this means something is fucked with PHP FPM.

  1. Confirm that FPM is not running:

    ps aux | grep fpm

    You 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.

  2. Check the PHP FPM error log to find out why it's not running:

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

  3. Try to resolve any errors you see. Here's a few common ones:

Problem: /var/run/valet/fpm.socket does not exist!

If you see an error similar to:

Unable to bind listening socket for address '/var/run/valet/fpm.socket': No such file or directory

...in /usr/local/opt/php70/var/log/php-fpm.log, you were probably running dev-master and have now switched back to tagged releases.

Valet 1.1.22 attempts to automate fixing this issue by explicitly configuring where PHP FPM should listen.

  1. Make sure ~/.composer/composer.json points to ^1.1.22:

    - "laravel/valet": "^1.1.19",
    + "laravel/valet": "^1.1.22",
  2. Run composer global update

  3. Run valet install

Problem: php-fpm.conf is missing!

Something went wrong when installing PHP through Homebrew. This seems to happen on fresh non-upgrade installations of macOS Sierra.

  1. Uninstall PHP 7: brew uninstall php70
  2. Reinstall PHP 7 from source: brew install php70 --build-from-source
  3. Re-run valet install

Where to Look for Errors

If you are still running into problems and are a capable adult, here's a list of log files to check:

  • Caddy start log:

    /tmp/com.laravel.valetServer.err

  • PHP FPM error log:

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

  • Caddy error log:

    ~/.valet/Log/error.log

@Keoghan

This comment has been minimized.

Show comment
Hide comment
@Keoghan

Keoghan Sep 22, 2016

Problem: 'Safari' cannot find 'XXX.dev' error.

In my case, it was caused by having 'secured' domains in an earlier version of Valet. Those domains caddy files had some references to the string VALET_HOME_PATH which was stopping Caddy from running as a daemon.

I removed the old caddy files from ~/.valet/Caddy for each secured domain and the re-secured them.

valet restart then all good.

Keoghan commented Sep 22, 2016

Problem: 'Safari' cannot find 'XXX.dev' error.

In my case, it was caused by having 'secured' domains in an earlier version of Valet. Those domains caddy files had some references to the string VALET_HOME_PATH which was stopping Caddy from running as a daemon.

I removed the old caddy files from ~/.valet/Caddy for each secured domain and the re-secured them.

valet restart then all good.

@dgrauers

This comment has been minimized.

Show comment
Hide comment
@dgrauers

dgrauers Sep 24, 2016

I had the "502 Bad Gateway error" and "php-fpm config missing" problem installing valet on macos sierra installed from scratch. Following the steps of "Problem: php-fpm.conf is missing!" wasn't enough to solve it but fortunately I finally fixed with some extra steps that I wrote here (just in case can help someone):

https://laracasts.com/discuss/channels/servers/trouble-with-valet-install

I had the "502 Bad Gateway error" and "php-fpm config missing" problem installing valet on macos sierra installed from scratch. Following the steps of "Problem: php-fpm.conf is missing!" wasn't enough to solve it but fortunately I finally fixed with some extra steps that I wrote here (just in case can help someone):

https://laracasts.com/discuss/channels/servers/trouble-with-valet-install

@mikemand

This comment has been minimized.

Show comment
Hide comment
@mikemand

mikemand Sep 25, 2016

After updating to Valet ^1.1.22, I had to set my domain TLD again (with valet domain <tld>). So if anyone is getting a

This site can’t be reached

or other DNS error (and you can't ping or dig the domain), try setting your domain again.

If you haven't changed your TLD from .dev, I would recommend doing so because .dev is a real, registered, TLD and it is a terrible idea to use a real TLD. You can pick something that isn't in the Root Zone Database (I use .lo because it is very short) or use a reserved TLD like .test, .example or, .localhost.

After updating to Valet ^1.1.22, I had to set my domain TLD again (with valet domain <tld>). So if anyone is getting a

This site can’t be reached

or other DNS error (and you can't ping or dig the domain), try setting your domain again.

If you haven't changed your TLD from .dev, I would recommend doing so because .dev is a real, registered, TLD and it is a terrible idea to use a real TLD. You can pick something that isn't in the Root Zone Database (I use .lo because it is very short) or use a reserved TLD like .test, .example or, .localhost.

@robbielove

This comment has been minimized.

Show comment
Hide comment
@robbielove

robbielove Sep 26, 2016

I spent over a day trying things to get my install working again after upgrading to macOS sierra and having it randomly stop working despite working for hours after upgrading, I had to update valet, brew and php70 and then finally got connection refused - a dns issue, valet was reporting my custom domain, however the dnsmasq config showed .dev had defaulted again. remapping the domain in valet fixed it.

I spent over a day trying things to get my install working again after upgrading to macOS sierra and having it randomly stop working despite working for hours after upgrading, I had to update valet, brew and php70 and then finally got connection refused - a dns issue, valet was reporting my custom domain, however the dnsmasq config showed .dev had defaulted again. remapping the domain in valet fixed it.

@jasperf

This comment has been minimized.

Show comment
Hide comment
@jasperf

jasperf Sep 28, 2016

Had issues as well. Got connection refused and it started after the upgrade to OSX Sierra. Opened a thread on it at Super User. Fortunately after an upgrade things started working again. Then I also found the Laravel News blog posts talking about troubleshooting referring to the gist here. Still rather slow and I do experience these errors today:

28/Sep/2016:09:11:21 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58756: write: broken pipe
28/Sep/2016:09:43:41 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58764: write: broken pipe
28/Sep/2016:09:53:24 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58759: write: broken pipe
28/Sep/2016:11:06:47 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:49573: write: broken pipe
28/Sep/2016:11:31:13 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58695: write: broken pipe
28/Sep/2016:11:31:21 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:59439: write: broken pipe

and no related errors at /usr/local/opt/php70/var/log/php-fpm.log , but things work most of the time. Happy it is working again now.

jasperf commented Sep 28, 2016

Had issues as well. Got connection refused and it started after the upgrade to OSX Sierra. Opened a thread on it at Super User. Fortunately after an upgrade things started working again. Then I also found the Laravel News blog posts talking about troubleshooting referring to the gist here. Still rather slow and I do experience these errors today:

28/Sep/2016:09:11:21 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58756: write: broken pipe
28/Sep/2016:09:43:41 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58764: write: broken pipe
28/Sep/2016:09:53:24 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58759: write: broken pipe
28/Sep/2016:11:06:47 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:49573: write: broken pipe
28/Sep/2016:11:31:13 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:58695: write: broken pipe
28/Sep/2016:11:31:21 +0300 [ERROR 502 /server.php] write tcp 127.0.0.1:80->127.0.0.1:59439: write: broken pipe

and no related errors at /usr/local/opt/php70/var/log/php-fpm.log , but things work most of the time. Happy it is working again now.

@RichardStyles

This comment has been minimized.

Show comment
Hide comment
@RichardStyles

RichardStyles Nov 4, 2016

Had a issues when switching from php70 to php71 and back again.

  1. rm -rf ~/.valet
  2. valet install

Solved the issue I had "no response" from chrome, yet nothing obvious appeared in the error logs.

Had a issues when switching from php70 to php71 and back again.

  1. rm -rf ~/.valet
  2. valet install

Solved the issue I had "no response" from chrome, yet nothing obvious appeared in the error logs.

@scottzirkel

This comment has been minimized.

Show comment
Hide comment
@scottzirkel

scottzirkel Nov 24, 2016

I had a conflict in Sierra with co.echo.httpdfwd.plist in /Library/LaunchDaemons. I could ping *.dev just fine, but I kept getting ERR_CONNECTION_REFUSED in the browser. Removed the file and restarted and all my sites started to load.

Found the fix here.

I had a conflict in Sierra with co.echo.httpdfwd.plist in /Library/LaunchDaemons. I could ping *.dev just fine, but I kept getting ERR_CONNECTION_REFUSED in the browser. Removed the file and restarted and all my sites started to load.

Found the fix here.

@PauBenetPrat

This comment has been minimized.

Show comment
Hide comment
@PauBenetPrat

PauBenetPrat Jan 27, 2017

I had valet and laravel running but there was no way to access to my parked applications. I installed valet2 as laravel page suggest (https://laravel.com/docs/5.3/valet). After trying to reinstall system, php71 in many ways an some more staff i had to downgrade valet to v 1.1.22 and php71 to php70 and that did the trick! I've got no idea way new valet release wasn't working :S

I had valet and laravel running but there was no way to access to my parked applications. I installed valet2 as laravel page suggest (https://laravel.com/docs/5.3/valet). After trying to reinstall system, php71 in many ways an some more staff i had to downgrade valet to v 1.1.22 and php71 to php70 and that did the trick! I've got no idea way new valet release wasn't working :S

@mnedoszytko

This comment has been minimized.

Show comment
Hide comment
@mnedoszytko

mnedoszytko Jan 29, 2017

Same for me - I got valet 2.0.3, installed according to Instruction.
Initially I couldn't ping *.dev domains, I got 127.0.53.53, instead of 127.0.0.1, after installing valet over sudo I could ping any host on domain I set through valet without any problem 127.0.0.1, however I can't open the sites in any browser, curl -O shows remote file name has no length.
Tried removing ~/.valet dir, reinstalling, and so on..
PHP 7.1.1, and I do not want to downgrade. Any ideas how to troubleshoot that?

Same for me - I got valet 2.0.3, installed according to Instruction.
Initially I couldn't ping *.dev domains, I got 127.0.53.53, instead of 127.0.0.1, after installing valet over sudo I could ping any host on domain I set through valet without any problem 127.0.0.1, however I can't open the sites in any browser, curl -O shows remote file name has no length.
Tried removing ~/.valet dir, reinstalling, and so on..
PHP 7.1.1, and I do not want to downgrade. Any ideas how to troubleshoot that?

@pyropoptrt

This comment has been minimized.

Show comment
Hide comment
@pyropoptrt

pyropoptrt Feb 10, 2017

@mnedoszytko Here is the method I used to get everything working:

  1. Deleted the ~/.valet directory
  2. brew unlink nginx && brew remove nginx
  3. brew unlink php56 && brew remove php56 && brew uninstall --ignore-dependencies php56
  4. brew unlink php71 && brew remove php71
  5. brew unlink dnsmasq && brew remove dnsmasq

After running those steps I did brew update and followed instructions on doing a fresh install. Another caveat, I had my folders already name project.dev so I had to rename them to just project. Hope this helps.

@mnedoszytko Here is the method I used to get everything working:

  1. Deleted the ~/.valet directory
  2. brew unlink nginx && brew remove nginx
  3. brew unlink php56 && brew remove php56 && brew uninstall --ignore-dependencies php56
  4. brew unlink php71 && brew remove php71
  5. brew unlink dnsmasq && brew remove dnsmasq

After running those steps I did brew update and followed instructions on doing a fresh install. Another caveat, I had my folders already name project.dev so I had to rename them to just project. Hope this helps.

@tommymarshall

This comment has been minimized.

Show comment
Hide comment
@tommymarshall

tommymarshall Feb 15, 2017

On new macOS Sierra, we were getting no response running ping foobar.dev after installation.

  1. rm -rf ~/.valet
  2. valet install

Like @RichardStyles mentioned above.

tommymarshall commented Feb 15, 2017

On new macOS Sierra, we were getting no response running ping foobar.dev after installation.

  1. rm -rf ~/.valet
  2. valet install

Like @RichardStyles mentioned above.

@simplenotezy

This comment has been minimized.

Show comment
Hide comment
@simplenotezy

simplenotezy Jun 17, 2017

What about something like this, but for Valet 2.0 @adamwathan?

What about something like this, but for Valet 2.0 @adamwathan?

@bsesic

This comment has been minimized.

Show comment
Hide comment
@bsesic

bsesic Dec 19, 2017

I always got a dns error when I wanted to access the page.
I tried a lot of things, reinstalling, reconfiguring dnsmasq and valet, etc.

What finally worked was simply to change the TLD to .test and it worked!

bsesic commented Dec 19, 2017

I always got a dns error when I wanted to access the page.
I tried a lot of things, reinstalling, reconfiguring dnsmasq and valet, etc.

What finally worked was simply to change the TLD to .test and it worked!

@melker-io

This comment has been minimized.

Show comment
Hide comment
@melker-io

melker-io Feb 17, 2018

If anyone is having trouble with "It Works!" and stopping Apache does not solve your issue, something else is running on port 80.

Open Acitvity Monitor>Memory and look for port 80. Unless it's something important, stop it by opening up that process and clicking Stop. Mine was running awdd (Apple/Wireless/Diagnostic/Data). Stopping it solved it for me.

melker-io commented Feb 17, 2018

If anyone is having trouble with "It Works!" and stopping Apache does not solve your issue, something else is running on port 80.

Open Acitvity Monitor>Memory and look for port 80. Unless it's something important, stop it by opening up that process and clicking Stop. Mine was running awdd (Apple/Wireless/Diagnostic/Data). Stopping it solved it for me.

@Maxcutex

This comment has been minimized.

Show comment
Hide comment
@Maxcutex

Maxcutex Apr 7, 2018

i am having the same problem on mac. installed valet 2.0 and done all the processes to setup valet. but i get 502 bad gateway and all the help above doesnt work

Maxcutex commented Apr 7, 2018

i am having the same problem on mac. installed valet 2.0 and done all the processes to setup valet. but i get 502 bad gateway and all the help above doesnt work

@ClaryPollack

This comment has been minimized.

Show comment
Hide comment
@ClaryPollack

ClaryPollack Apr 18, 2018

@Maxcutex me too :*( I just bought a new MacBook Pro on Sunday and have been trying to get this rolling for three days now. Crazy, isn't it? Will let u know if I figure out what the issue is (and pls feel free to do the same). Cheers.

@Maxcutex me too :*( I just bought a new MacBook Pro on Sunday and have been trying to get this rolling for three days now. Crazy, isn't it? Will let u know if I figure out what the issue is (and pls feel free to do the same). Cheers.

@markstachowski

This comment has been minimized.

Show comment
Hide comment
@markstachowski

markstachowski Apr 22, 2018

Mine also has this issue and I installed a brand new copy of macOS "not" beta at all on it.

Mine also has this issue and I installed a brand new copy of macOS "not" beta at all on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment