Valet (Laravel): DNS address can not be found
Asked Answered
K

5

13

I'm trying out Valet, it looks really nice from what I've heard.

I've been trough the "whole" installation process, Valet is succesfully installed.

But when I cd into my projects file and enter valet park and browse to http://blog.dev, I get "The DNS server address of blog.dev can not be found."

I have no idea what I'm doing wrong. :)

Khosrow answered 11/5, 2016 at 20:29 Comment(8)
why do you browse to http://blog.dev?Kinin
its not very important how you call your project, why do you use this domain name? have you bought it and configured to point to your ip address?Kinin
Have you follow this tutorial step by step? laravel.com/docs/5.2/valetLanoralanose
When you ran valet install, did it successfully install dnsmasq? Run brew services list and ensure dnsmasq is there and running. If it is, run valet start and confirm it's running. Next ensure that you're not running another installation of Apache or Nginx on port 80. Also, ensure that you're running PHP with FPM; you might need to run brew uninstall php70; brew install php70 --with-fpmWaisted
@Lashane Valet maps {dir-name}.dev using dnsmasq to {parked dir}/{dir-name} automatically.Waisted
@Khosrow furthermore, you can probably rule out the dnsmasq issues by simply pinging blog.dev in your terminal. If it receives a response from 127.0.0.1 it's likely working and you'll probably find you simply have another web server responding instead of Caddy. OSX has Apache installed so perhaps try stopping it first with sudo apachectl stop and restarting ValetWaisted
My problem was that dnsmasq needed to be started with sudo in order to have permission to listen on the port.Gird
Do NOT use the .DEV TLD to name any of your internal resources. This is a valid existing and delegated TLD in the IANA root, it is operated by Google and will "soon" be open for registrations. In the mean time it is already in the HSTS preloading list, so that will create you all sort of problems if you name your internal resources with it. Register a domain name, in any TLD, and then use it or a subdomain out of it to name all your internal resources.Kibe
W
43

When you run valet install it attempts to install dnsmasq. It requires sudo privileges.

You can check that it's installed and running using

brew services list

You should see something like

dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

You may however need to tap brew/services first

brew tap homebrew/services

If it's not there, run

brew install dnsmasq
brew services start dnsmasq

Run valet install again to set up dnsmasq and keep an eye out for any errors. What this should do is append a line to the bottom of /usr/local/etc/dnsmasq.conf similar to

conf-file=/Users/{YOURUSER}/.valet/dnsmasq.conf

/Users/{YOURUSER}/.valet/dnsmasq.conf then should contain

address=/.dev/127.0.0.1

Check that your dns server is responding to requests

dig testing.dev @127.0.0.1

You should see a response like

;; ANSWER SECTION:
testing.dev. 0 IN   A   127.0.0.1

To actually ensure that your Mac knows that it should resolve *.dev using your local DNS server, it need to be told to do so. Valet also handles this for you but you can check if it's done it's job by doing the following.

Inside the directory /etc/resolver, there should be a file entitled dev with the following contents

nameserver 127.0.0.1

This creates a custom DNS resolver for *.dev and points all requests at your local DNS server.

Restart dnsmasq with either of the following commands and then give it a try again.

// this
brew services restart dnsmasq

// or this
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq

If this is all working, you should be able to ping anything.dev

ping anything.dev

PING anything.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.081 ms

That ensures the DNS related bits are working.


Ultimately the question is about DNS related problems but as this started off as a here's everything you need to have tried, I'll leave this below. That said, if you're unable to ping something.dev or get an error like "The DNS server address of blog.dev can not be found." as per the OP, it's something above to do with DNS which needs resolving.

Since Caddy serves websites on port 80, you need to ensure that nothing else is running on port 80.

sudo lsof -n -i:80 | grep LISTEN

Ideally this should return caddy if valet is running as expected. You want to see the example below or nothing ideally; nothing because it means we can just start Valet.

caddy     76234 root    3u  IPv6 0x4f871f962e84fa95      0t0  TCP *:http (LISTEN)

You may see other webservers, such as Apache or Nginx (and their child processes, _www and nobody) in the example below.

httpd       79     root    4u  IPv6 0xf4641199930063c5      0t0  TCP *:http (LISTEN)
httpd      239     _www    4u  IPv6 0xf4641199930063c5      0t0  TCP *:http (LISTEN)
nginx     4837     root    6u  IPv4 0xf4641199a4e8e915      0t0  TCP 127.0.0.1:http (LISTEN)
nginx     4838   nobody    6u  IPv4 0xf4641199a4e8e915      0t0  TCP 127.0.0.1:http (LISTEN)

Assuming you've installed Nginx with homebrew you can run the following to stop it.

brew services stop nginx

OSX ships with Apache installed so you can stop with with the following if it's running.

sudo apachectl stop

At this point you can likely start Valet with valet start and it'll work.

You may get a further error which is caused by PHP being installed without FPM. You can check this using

brew info php70 | grep php70-fpm

Which should yield something along the lines of

The control script is located at /usr/local/opt/php70/sbin/php70-fpm

If it doesn't appear to be installed, use the following.

brew uninstall homebrew/php/php70
brew install homebrew/php/php70 --with-fpm
valet restart
Waisted answered 11/5, 2016 at 22:22 Comment(10)
I get stuck at the part where I run "ping anything.dev". ping: cannot resolve anything.dev: Unknown hostKhosrow
Give valet install another go now that you've ensured dnsmasq is there. May also be worth running brew update and brew doctor first to ensure your homebrew installation is as expected.Waisted
I'm having the exact same issueAusterlitz
sudo apachectl start should be sudo apachectl stopFolderol
I like the comprehensiveness of this answer, but it doesn't yet solve my problem. When I ping test.dev the response is ping: cannot resolve test.dev: Unknown host ... That said, one thing I noticed missing from this answer is to check your root projects folder is seen when you valet paths. If it's not, then cd to the folder that holds your projects and valet park. Unfortunately this all still doesn't solve my problem, but thought it would be good to add to this answer.Folderol
@NateRitter I've updated to apachectl stop, cheers. I've also updated the answer with some other things to check to ensure that dnsmasq is working as expected and how to configure it if not. dnsmasq is what handles the *.dev bit independent of valet so whilst it seems perhaps that valet may have failed to set it up properly, it can be resolved without valet at all.Waisted
@BenSwinburne Brilliant! Your additions helped me figure out the DNS issue I was having and I upgraded dnsmasq as well. Thank you!Folderol
No worries. Glad I could help.Waisted
Checked out all and trouble shooted based on your input. In the end I realized I had to remove 8.8.8.8 as DNS server in network settings of my Mac Mini. After that I could ping the hosts without getting: ping foobar.dev PING foobar.dev (127.0.53.53): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1Ethel
After several responsen on others post, this is de the best. Explain mechanism of dnsmasq. Work for me, and my issue when restart forced my iMac.Housemaid
B
3

I had the same problem - getting stuck at ping foobar.dev - and fixed it by restarting my Macbook (after valet install). I am sure this is not an exact solution and I reckon there is a way to do this without restarting. Yet, it worked for me. I did not have to do any other steps.

[Edit - Additionally, before restarting I made sure to try the installing with fpm tip, and to follow all brew's suggestions upon installing php70 (tweaking the path, making sure php70 starts on system start. I cannot say whether these things helped, so probably want to try just restarting, first. If it's really just a restart that's required, or some other additional step to properly start services, I think the laravel documentation probably needs some clarification.]

Bignonia answered 1/6, 2016 at 20:55 Comment(0)
A
3

I had the same problem, post installation I got stuck at pinging foo.dev.

I checked for running services.

> brew services list

Name    Status  User Plist
dnsmasq stopped
nginx   stopped
php71   stopped

Started all the three services manually with

> brew services start dnsmasq
> brew services start nginx
> brew services start php71

Ran valet install.

Ping successfully to foo.dev

Amar answered 17/2, 2017 at 5:48 Comment(0)
M
1

If you are a Windows user, Perform the Acrylic Configuration then restart your adapter(Disable and Enable)

http://mayakron.altervista.org/wikibase/show.php?id=AcrylicWindows10Configuration

Worked For Me

Misguidance answered 29/9, 2018 at 22:12 Comment(0)
K
0

in my case

This site can’t be reachedCheck if there is a typo in snippet-generator-build.test.
DNS_PROBE_FINISHED_NXDOMAIN

i have tried to bypass reddit by chrome://settings/security with setting use Secure DNS and choose Cloudflare(1.1.1.1) when i test on my safari browser its work , but on chrome it doesnt work because i have ever setting DNS on my chrome. when i change to default i can access my address setting by valet on my chrome.

Kitty answered 23/12, 2023 at 3:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.