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. :)

sseraluck
  • 203
  • 1
  • 2
  • 8
  • why do you browse to `http://blog.dev`? – Iłya Bursov May 11 '16 at 20:35
  • 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? – Iłya Bursov May 11 '16 at 20:36
  • 1
    Have you follow this tutorial step by step? https://laravel.com/docs/5.2/valet – Felippe Duarte May 11 '16 at 20:38
  • 1
    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-fpm` – Ben Swinburne May 11 '16 at 21:27
  • 1
    @Lashane Valet maps `{dir-name}.dev` using dnsmasq to `{parked dir}/{dir-name}` automatically. – Ben Swinburne May 11 '16 at 21:29
  • 1
    @sseraluck 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 Valet – Ben Swinburne May 11 '16 at 21:32
  • My problem was that [dnsmasq needed to be started with sudo](https://github.com/Homebrew/legacy-homebrew/issues/26293#issuecomment-34048948) in order to have permission to listen on the port. – Ian Dunn Jan 21 '17 at 23:18
  • 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. – Patrick Mevzek May 25 '18 at 14:07

4 Answers4

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
Ben Swinburne
  • 25,669
  • 10
  • 69
  • 108
  • 4
    I get stuck at the part where I run "ping anything.dev". `ping: cannot resolve anything.dev: Unknown host` – sseraluck May 14 '16 at 18:13
  • 2
    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. – Ben Swinburne May 18 '16 at 09:36
  • I'm having the exact same issue –  May 30 '16 at 19:05
  • `sudo apachectl start` should be `sudo apachectl stop` – Nate Ritter Jun 09 '16 at 07:04
  • 2
    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. – Nate Ritter Jun 09 '16 at 07:07
  • 1
    @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. – Ben Swinburne Jun 09 '16 at 10:30
  • @BenSwinburne Brilliant! Your additions helped me figure out the DNS issue I was having and I upgraded dnsmasq as well. Thank you! – Nate Ritter Jun 09 '16 at 15:50
  • No worries. Glad I could help. – Ben Swinburne Jun 09 '16 at 16:06
  • 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 1` – rhand Sep 08 '16 at 08:20
  • 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. – abkrim May 12 '17 at 04:18
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.]

FQuist
  • 61
  • 5
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

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