Skip to content

Instantly share code, notes, and snippets.

@adamwathan
Last active January 19, 2021 04:14
Show Gist options
  • Star 75 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save adamwathan/6ea40e90a804ea2b3f9f24146d86ad7f to your computer and use it in GitHub Desktop.
Save adamwathan/6ea40e90a804ea2b3f9f24146d86ad7f to your computer and use it in GitHub Desktop.
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

@ClaryPollack
Copy link

@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
Copy link

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

@HYR
Copy link

HYR commented Jul 31, 2018

Just want to add that before Valet started working for me I had to restart my whole system.

@EricBusch
Copy link

EricBusch commented Aug 17, 2018

I'm running El Capitan and got the 502 Bad Gateway error. Here's what I did to fix it.

After running this brew list | grep php I saw that I had 4 different versions of PHP installed:

  • php
  • php71-xdebug
  • php72
  • php@7.1

So I did the following though I'm not exactly sure which step fixed the 502 error.

brew upgrade nginx - Upgraded Nginx from 1.12.2_1 to 1.15.2

Then, as per this article, ran the following command:

brew list | grep php | while read x; do brew uninstall --force $x;
done

That left me with the following installs of PHP:

  • php
  • php72

Next, I ran brew upgrade php which upgraded PHP from php 7.2.3_1 to 7.2.9.

Finally, I ran valet install for good measure.

This fixed the 502 Bad Gateway on Mac El Capitan encountered when trying to run Valet.

@haleyngonadi
Copy link

@EricBusch your solution worked perfectly for me. Thank you!

@regal2157
Copy link

@EricBusch thanks! For me all I needed to do was upgrade nginx via brew and run valet install. It seemed to be okay with my variety of PHP installs

@mattias-persson
Copy link

mattias-persson commented Mar 10, 2019

If anyone has problems with connecting to MySQL, getting Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory") or Can't connect to MySQL server on '127.0.0.1' (61), try running the following:

mkdir /usr/local/etc/my.cnf.d.

Brew seems to sometimes prune this folder as specified here: Homebrew/legacy-homebrew#31760.

@jake-101
Copy link

I had this issue "dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error" and PHP wasn't being found. Running brew upgrade and brew cleanup fixed it.

@renepardon
Copy link

Looks like valet is running smoothly and then the next page refresh I just receive ERR_CONNECTION_CLOSED. I tried already restarting, upgrading, etc. I may switch back to manual setup/docker. So sad. The idea behind valet is so nice.

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