laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.52k stars 698 forks source link

No valet.sock file found #441

Closed dkrasov closed 6 years ago

dkrasov commented 7 years ago

Hey guys, I'm on my new Mac OS Sierra (fresh install) and trying to get valet working. It was okay for a while, but after rebooting my Mac nginx started to throw me 502 error. In nginx error log I've found the next lines:

2017/09/22 10:37:55 [crit] 12719#0: *4 connect() to unix:/Users/MYUSER/.valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /robots.txt HTTP/1.1", upstream: "fastcgi://unix:/Users/MYUSER/.valet/valet.sock:", host: "foobar.dev"

I've tried almost everything:

What am I doing wrong?

drbyte commented 7 years ago

Sounds like PHP isn't started properly, as nginx can't find phpfpm on the valet.sock socket.

Or else the edit to the default php configuration didn't work properly: https://github.com/laravel/valet/blob/master/cli/Valet/PhpFpm.php#L63

mattstauffer commented 6 years ago

@dmitriymarley I'm closing this as you haven't responded--but if you find that @drbyte's response hasn't helped, please feel free to re-open.

raveenasurani commented 6 years ago

Hello guys,

I was having the same issue after knocking my head around i came upto this solution and its working perfectly .. Here you go 👍

so Firstly, i install Brew : /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then i installed php71 which is now php@7.1 : brew install php71

-> after installation export : echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile

-> brew link php@7.1 --force --overwrite

->ln -s $(which php) /usr/local/bin/php

Then i installed composer using :

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"

and mv composer.phar /usr/local/bin/composer

and then installed valet : composer global require laravel/valet

And then comes the tricky part :

-> open -e /Users/USERNAME-Directory/.composer/vendor/laravel/valet/cli/Valet/Brew.php

and alter

function supportedPhpVersions() { return collect(['php', 'php72', 'php71', 'php70', 'php56','php@7.1']); }

-> open -e /Users/USERNAME-Directory/.composer/vendor/laravel/valet/cli/Valet/PhpFpm.php

and alter

function fpmConfigPath() { $confLookup = [ 'php' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf', 'php72' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf', 'php71' => '/usr/local/etc/php/7.1/php-fpm.d/www.conf', 'php70' => '/usr/local/etc/php/7.0/php-fpm.d/www.conf', 'php56' => '/usr/local/etc/php/5.6/php-fpm.conf', 'php@7.1' => '/usr/local/etc/php/7.1/php-fpm.d/www.conf' ];

return $confLookup[$this->brew->linkedPhp()];

} and then final step : sudo brew services restart nginx && sudo brew services restart php@7.1

And DONE!!!!

Cheers!!

sebastianjung commented 5 years ago

Wow, that actually worked for me as well!

One thing i had to do afterwards though:

valet install

Thanks!

therealchiko commented 5 years ago

Just valet install did it for me. Also kept my previous config as it was, which is awesome.

yratof commented 3 years ago

Writing this here incase it helps anyone in 2021 - I had to copy /usr/local/etc/php/8.0/php-fpm.d/valet-fpm.conf to /usr/local/etc/php/8.0/php-fpm.conf. This solved my issue of the 502 error. Looking at the php-fpm logs revealed that the conf file wasn't being loaded - because it didn't exist. I'm guessing there's a reason for this, but working with only valet, it was easier to clone the file and rename it, than to spend my life figuring out why the server gods reject me so

ebabajan commented 3 years ago

@yratof Thank you. I found your answer working for me. Thanks for sharing

vardumper commented 3 years ago

thanks a bunch @yratof after spending a lifetime (2 days) on this, your suggestion helped.

alqahtani commented 2 years ago

@yratof Thank you! you're a life saver

noeurphireak commented 2 years ago

@yratof Thanks you. u saved me

coreation commented 2 years ago

In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it

Just in case the reply in the link is removed:

cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

Groganj89 commented 2 years ago

cd /opt/homebrew/etc/php/8.1 sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

@coreation Thank you so much, had this issue for 2 days now! <3

coreation commented 2 years ago

cd /opt/homebrew/etc/php/8.1 sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

@coreation Thank you so much, had this issue for 2 days now! <3

Ah, great to hear it served at least 1 person @Groganj89 ! These kind of things are very tedious to fix ;) Have a good one!

Groganj89 commented 2 years ago

cd /opt/homebrew/etc/php/8.1 sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

@coreation Thank you so much, had this issue for 2 days now! <3

Ah, great to hear it served at least 1 person @Groganj89 ! These kind of things are very tedious to fix ;) Have a good one!

You too bud! thank you again :)

EvidenceEkanem commented 1 year ago

In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it

Just in case the reply in the link is removed:

cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

thank you bro, you just saved me a week of uninstalling and installing php on my m1 mac

coreation commented 1 year ago

In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it Just in case the reply in the link is removed: cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

thank you bro, you just saved me a week of uninstalling and installing php on my m1 mac

You're very welcome, have a good one!

abzal0 commented 1 year ago

brew update composer global require laravel/valet valet install

these worked for me

Slaycaster commented 11 months ago

In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it

Just in case the reply in the link is removed:

cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf

I did this but with php 8.2 and it still works!!! Thanks for this

congkhuong commented 4 months ago

Writing this here incase it helps anyone in 2021 - I had to copy /usr/local/etc/php/8.0/php-fpm.d/valet-fpm.conf to /usr/local/etc/php/8.0/php-fpm.conf. This solved my issue of the 502 error. Looking at the php-fpm logs revealed that the conf file wasn't being loaded - because it didn't exist. I'm guessing there's a reason for this, but working with only valet, it was easier to clone the file and rename it, than to spend my life figuring out why the server gods reject me so

It works for me, i spend 4 hours to figure it out. You made my day

ejames17 commented 2 months ago

valet install This worked for me.