Laravel valet not working

天大地大妈咪最大 提交于 2019-12-03 13:55:28

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

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)

Rick Bolton

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!

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!