Laravel valet not working
Asked Answered
D

6

11

I use OSX El Capitan and PHP 7. I followed the installation guide so I install Laravel Valet version v1.1.3 successfully. I ping foo.dev or any.dev then the terminal prints

"64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.116 ms"

Everything is ok. My directory /User/mickey/Sites is added to Valet's paths. I created a Laravel 5.2 project named blog, then run the project with php artisan serve ok but when i accessed url blog.dev on the browser, the browser said

This site can’t be reached, blog.dev refused to connect. ERR_CONNECTION_REFUSED.

I don't know what is the problem with my installation. Thanks in advance!

Dowdy answered 10/5, 2016 at 10:22 Comment(3)
any chance you have a firewall?Connective
@FelippeDuarte: I already turned off firewallDowdy
flush the DNS, dscacheutil -flushcacheOphthalmologist
A
24

You needn't run php artisan serve as Valet runs Caddy in the background.

Here're a few troubleshooting points.

  • Ensure that you don't have Apache (or anything else running on port 80)

    sudo apachectl stop

  • Ensure that Valet is running

    valet start

  • Ensure that PHP was installed with FPM

    brew uninstall homebrew/php/php70

    brew install homebrew/php/php70 --with-fpm

Amazement answered 11/5, 2016 at 21:46 Comment(6)
I run the php artisan serve in the blog directory just to make sure the project is working as normal. I also installed php7 with fpm and start valet, stop Apache but still can't access to blog.dev.Dowdy
When i run sudo lsof -i :80, only caddy is appear.Dowdy
Have you removed any references to *.dev from your /etc/hosts file? Perhaps blog.dev is directing to another IP, perhaps Homestead or somewhere.Amazement
Here is my hosts file: 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhostDowdy
Stopping Apache worked for me. Had some wacky configuration running that I totally forgot about. Thanks!Terramycin
Great stopping apache is worked for me also, by default the valet is parking to mamp when you stop serving apache it works :) ThanksDeathful
E
17

After trying everything I found on the internet (including this one which worth to try) for me the solution was to change valet's domain to test.

valet domain test

So I have no idea if the mentioned reinstall was needed or not but I know that I could ping or even curl my .dev sites but could not open them in any browser (Chrome nor Safari). Then I tried to set domain to .app but that did not work either. In the browsers I was redirected all the time to https even after running valet unsecure.

But then changed domain to .test and suddenly it started to work. I'm not sure what is the real issue here and why is this but I'm okay with it since it works again.

I've also read that .dev is not good any more because it's an official TLD and so reserved. (wikipedia)

Entrench answered 27/2, 2018 at 13:23 Comment(1)
Same as you Mr. I tried all the things here and there. But every thing was failing for me. And finally i read your comment here. Coz i had also changed my domain to *.dev from *.test And then I thought let's give it a try. So i changed it back to the *.test and it worked. Like you sir, i don't know why it behaved. But your comment did work for me. Thank you.Helenehelenka
B
5

I had nearly the same issue of Laravel Valet not working after installing via Homebrew on macOS 10.13 "High Sierra".

The problem I encountered was that DNSMasq would respond to queries, but Nginx would not handle the responses on port 80.

Attempting to connect to the site in a Terminal session would result in the following error:

$ curl -IL http://example.test/
curl: (7) Failed to connect to example.test port 80: Connection refused

I had recently upgraded from macOS 10.2 "Sierra" to 10.13 "High Sierra", so I suspected my Homebrew environment and configuration that was brought by the Migration Assistant could be at fault.

While following the troubleshooting advice here and elsewhere, what eventually solved my problem was to completely uninstall and remove Valet along with its dependencies (PHP, Nginx, DNSMasq, etc):

$ rm -rf ~/.valet
$ brew unlink nginx && brew remove nginx
$ brew unlink php56 && brew remove php56 && brew uninstall --ignore-dependencies php56
$ brew unlink php72 && brew remove php72
$ brew unlink dnsmasq && brew remove dnsmasq

With a clean slate, I was able to successfully install Valet:

$ brew update
$ brew install homebrew/core/php
$ composer global require laravel/valet
$ valet install

I then setup a new development domain:

$ valet domain test
$ valet park ~/Sites
$ mkdir ~/Sites/example && cd "$_"
$ valet link
$ echo "Hello, world" > ~/Sites/example/index.html

With Valet installed, I verified everything was working:

$ valet --version
$ sudo nginx -t
$ ping -c 4 example.test
$ curl -IL http://example.test/
$ valet open example

After doing all of this, I had a 100% successful working Laravel Valet environment.

Burns answered 13/4, 2018 at 17:3 Comment(0)
P
1

Hopefully I can now solve this one for you. The Self Control fix worked as a temp fix for me so you may be in luck as I've found a permanent solution for me!

I once had a httpd setup which I followed a guide to install. This came with some baggage as the guide got you to forward 127.0.0.1 port 80 to port 8080.

Try this anyway Go > Go to folder...

/Library/LaunchDaemons/

The file in my case was called co.echo.httpdfwd.plist which I just needed to delete and then restart my Mac. See my question for more info Laravel Valet not working. 127.0.0.1 Connection Refused.

Let me know how you get on!

Panic answered 12/7, 2016 at 23:11 Comment(2)
This is not a solutions, just a "hack" for making it work again... I will not restart my Macbook because there is a way to fix this the "right" way.Analogical
Clearly haven't read the whole answer correctly? Self Control was a hack to fix it yes. The actually reason why it wasn't working is because there was a file called co.echo.httpdfwd.plist within my /Libray/LaunchDaemons/ directory that forwarded 127.0.0.1:80 to port 8080 as the apache setup listened on 8080. Self Control hacked it as it overrides these files by adding its own files to the LaunchDaemons folder. Expand on your issue and I will try and help you fix it..Panic
B
1

in my case, I encountered this after putting my mac to sleep but fixed it by running:

valet stop

and then

valet start

Boggart answered 20/11, 2021 at 22:9 Comment(0)
D
0

The problem was solved by starting self-control app. I don't know the reason but you can try to download and start this app to resolve this problem.

Dowdy answered 28/6, 2016 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.