Laravel Valet安装后,ping test.dev会返回“未知主机". [英] Pinging test.dev after Laravel Valet install returns "Unknown Host"

查看:323
本文介绍了Laravel Valet安装后,ping test.dev会返回“未知主机".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:请勿使用".dev".最初于2016年发布时,还不错.现在不是.首先将您的TLD更改为".localhost"之类的名称. (此更改不会解决我的问题,但是如果您仍在使用".dev",则可能会解决您的问题.)

Update: Don't use ".dev". When this was originally posted in 2016, it was fine. Now it's not. Start by changing your TLD to somethinge else like ".localhost" or whatever. (This change would not have fixed my issue, but it might fix yours if you're still using ".dev").

问题:我已经安装了Laravel Valet,并且似乎一切正常,除了当我ping test.dev(它仅包含index.htm文件并且位于~/Sites中)之后,挂了很长时间我得到了响应ping: cannot resolve test.dev: Unknown host

Problem: I've installed Laravel Valet and it all seems to be working except when I ping test.dev (which just contains an index.htm file and is located in ~/Sites), after hanging for a long time I get the response ping: cannot resolve test.dev: Unknown host

这是我已经完成的事情:

Here's what I've already done:

  • 我已经查看过 Laravel Valet文档,并且一切都安装良好.
  • Apache未运行
  • /etc/hosts没有提及test.dev
  • 我正在使用代客v1.1.12
  • 我已经重新启动计算机
  • 我已经通过homebrew fresh和--with-fpm
  • 安装了php 7.0.7
  • 我的$PATH包含$PATH:$HOME/.composer/vendor/bin
  • sudo lsof -n -i:80 | grep LISTEN返回caddy proc
  • brew services list返回dnsmasq并启动
  • 我已经更新了brew,运行brew doctor,一切都很好
  • 我可以成功启动和停止代客服务.
  • valet paths成功返回: [ "/Users/nateritter/.valet/Sites", "/Users/nateritter/Sites" ]
  • test目录中使用valet link对此问题没有影响
  • I've gone through the Laravel Valet docs and everything installed fine.
  • Apache is not running
  • /etc/hosts contains no mention of test.dev
  • I'm on valet v1.1.12
  • I've restarted my computer
  • I've installed php 7.0.7 via homebrew fresh and --with-fpm
  • My $PATH contains $PATH:$HOME/.composer/vendor/bin
  • sudo lsof -n -i:80 | grep LISTEN returns the caddy proc
  • brew services list returns dnsmasq and is started
  • I've updated brew, run brew doctor and all is good there
  • I can start and stop valet successfully.
  • valet paths returns successfully: [ "/Users/nateritter/.valet/Sites", "/Users/nateritter/Sites" ]
  • Using valet link inside the test directory has no effect on this issue

现在,除了所有这些,我决定尝试所有代客参数. valet share似乎在某一点上出现了错误,这很有趣,但是我不确定这与原始问题有什么关系.

Now, in addition to all this, I decided to try all the valet arguments out. valet share seemed to bork with an error at one point, which is interesting but I'm not sure it has anything to do with the original issue.

ERROR: Tunnel 'command_line' specifies invalid address 'test.dev:80': unexpected '[' in address test.dev:80

此后,我得到21行Failed to connect to 127.0.0.1 port 4040: Connection refused,然后是一个异常:

After this I get 21 lines of Failed to connect to 127.0.0.1 port 4040: Connection refused and then an exception:

[Httpful\Exception\ConnectionErrorException]                                                                              
Unable to connect to "http://127.0.0.1:4040/api/tunnels": 7 Failed to connect to 127.0.0.1 port 4040: Connection refused                                                                                                                              

fetch-share-url

推荐答案

问题最终与dnsmasq有关.使用非常详尽的此答案在另一个相关的SO帖子中,我最终做了以下操作来解决我的问题:

The problem ended up being something to do with dnsmasq. Using the very thorough this answer to another related SO post, I ended up doing the following to solve my issue:

brew unlink dnsmasq

brew install dnsmasq

brew prune

brew services restart dnsmasq

valet install

然后,只是为了在执行ping操作之前进行测试,我做了dig test.dev并且响应包括:

Then, just to test before I did a ping, I did dig test.dev and the response included:

;; ANSWER SECTION:
test.dev.       3599    IN  A   127.0.53.53

我不确定为什么IP是127.0.53.53而不是127.0.0.1,但是当我执行ping test.dev时,它确实返回了...

I'm not sure why the IP is 127.0.53.53 and not 127.0.0.1 but when I did a ping test.dev it did return ...

PING test.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.036 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.072 ms

浏览test.dev也可以.

Browsing to test.dev worked as well.

需要注意的一件事是,我尚未调查的内容是index.htm没有被代客/球童识别为潜在的索引文件.不是问题的一部分,但是有一点需要注意.

One thing to note that I haven't looked into yet is that index.htm is not recognized by valet/caddy as a potential index file. Not part of the issue, but something interesting to note.

这篇关于Laravel Valet安装后,ping test.dev会返回“未知主机".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆