Laravel Valet 共享 - 无法连接到 127.0.0.1 端口 4040:连接被拒绝

Posted

技术标签:

【中文标题】Laravel Valet 共享 - 无法连接到 127.0.0.1 端口 4040:连接被拒绝【英文标题】:Laravel Valet share - Failed to connect to 127.0.0.1 port 4040: Connection refused 【发布时间】:2019-02-12 04:30:48 【问题描述】:

我已经在 Laravel 项目中设置了 Valet 并且运行良好。我可以访问 mysite.test 并按应有的方式加载项目。但是,当我运行命令 valet share 时,我收到“无法连接到 127.0.0.1 端口 4040:连接被拒绝”错误。

我已经尝试更新作曲家,更新自制软件并重新安装代客,但错误消息仍然存在。如果我运行 brew services list 以下服务都显示为正在运行;

dnsmasq   started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mysql@5.7 started root /Library/LaunchDaemons/homebrew.mxcl.mysql@5.7.plist
nginx     started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       started root /Library/LaunchDaemons/homebrew.mxcl.php.plist

我不相信 Apache 正在运行。当我尝试停止该服务时出现以下错误;

/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service

运行代客共享后收到的完整错误如下。

ERROR:  Tunnel 'command_line' specifies invalid address 'Sites.
ERROR:  Warning: Class 'Tightenco\Collect\Support\Debug\Dumper' not found in /Users/darren/.composer/vendor/tightenco/collect/src/Collect/Support/alias.php on line 18
ERROR:  
ERROR:  Warning: Class 'Tightenco\Collect\Support\Debug\htmlDumper' not found in /Users/darren/.composer/vendor/tightenco/collect/src/Collect/Support/alias.php on line 18
ERROR:  test:80': too many colons in address Sites.
ERROR:  Warning: Class 'Tightenco\Collect\Support\Debug\Dumper' not found in /Users/darren/.composer/vendor/tightenco/collect/src/Collect/Support/alias.php on line 18
ERROR:  
ERROR:  Warning: Class 'Tightenco\Collect\Support\Debug\HtmlDumper' not found in /Users/darren/.composer/vendor/tightenco/collect/src/Collect/Support/alias.php on line 18
ERROR:  test:80
Darrens-MacBook-Pro:Sites darren$ Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused
Failed to connect to 127.0.0.1 port 4040: Connection refused

In Request.php line 1028:

  Unable to connect to "http://127.0.0.1:4040/api/tunnels": 7 Failed to conne  
  ct to 127.0.0.1 port 4040: Connection refused                                


fetch-share-url

我相信 PHP 类警告是无关的。任何尝试解决此问题的帮助将不胜感激。

编辑:

运行 sudo brew services start --all 以确保所有服务确实已启动导致以下错误;

/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist: service already loaded
Error: Failure while executing; `/bin/launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist` exited with 133.

【问题讨论】:

【参考方案1】:

经过几个小时的调试,终于解决了这个问题。特别是在此过程中更新了“symfony/polyfill-php72”、“symfony/var-dumper”、“tightenco/collect”,因此问题一定出在其中一个软件包上。其他所有包都是从缓存中加载的。

composer global remove laravel/valet

composer self-update

composer global require laravel/valet

valet install

valet restart

【讨论】:

这行得通,这是一个班轮composer global remove laravel/valet && composer self-update && composer global require laravel/valet && valet install && valet restart

以上是关于Laravel Valet 共享 - 无法连接到 127.0.0.1 端口 4040:连接被拒绝的主要内容,如果未能解决你的问题,请参考以下文章

Laravel Valet托管网站返回Chrome中的“无法访问网站”

Laravel 4.2 + Laravel Valet + PHP 7 = 需要 Mcrypt PHP 扩展

无法将 Laravel 连接到 MailChimp(laravel 5.4)

cURL + Laravel Valet + dnsmasq 不工作

我的 Laravel 项目无法连接到 XAMPP 数据库

Laravel 5.1 SSH - 无法连接到远程服务器