Valet: Valet is not working after I renamed my mac username

Created on 18 Nov 2018  Â·  9Comments  Â·  Source: laravel/valet

I installed valet couple of days ago, it was working fine then. But today it's not working anymore. And by not working I mean it's not responding to any url at all. I have all my laravel projects in my ~/code directory. When I execute ping foobar.test the shell responds: ping: cannot resolve foobar.test: Unknown host.

Also unable to access project.test from the address bar. I have parked the ~/code directory.

The only notable change that I made was I renamed my mac username (account name).

So I thought that might have messed up valet, and I uninstalled it and reinstalled, but still no luck. What can I do?

Output of brew services list:

dnsmasq   started root   /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
[email protected] started tanmay /Users/tanmay/Library/LaunchAgents/[email protected]
nginx     started root   /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       started root   /Library/LaunchDaemons/homebrew.mxcl.php.plist
redis     stopped

Most helpful comment

ALSO, since you did the rename, perhaps the master /usr/local/etc/dnsmasq.conf still has reference to the old user?

Yes that was the case, later I removed/uncommented the one with the old user's reference:

# Comment this line:
# conf-file=/Users/OLD_USER_NAME/.config/valet/dnsmasq.conf

# Keep this line:

conf-file=/Users/NEW_USER_NAME/.config/valet/dnsmasq.conf

You may close the issue now.

All 9 comments

  1. Could you update the Title of this issue to add "after I renamed my mac username".

  2. Valet relies on the dnsmasq service to handle domain name resolution. Its config file is placed in your user's home directory, and the master dnsmasq config is updated to point to your user's home directory to look for that config. When you renamed your user it wouldn't know about the change. Delete your ~/.config/valet/dnsmasq.conf file so it knows it needs to reconfig that.
    Run valet tld test to have it reset all your site configs.
    Then run valet install again to have it rebuild the dnsmasq config.

@drbyte I executed your instructions step by step. Still the error persists: ping: cannot resolve foobar.test: Unknown host

Here is the output of most recent terminal commands:

➜  ~ cat ~/.config/valet/dnsmasq.conf
address=/.test/127.0.0.1
listen-address=127.0.0.1
➜  ~ rm -rf ~/.config/valet/dnsmasq.conf
➜  ~ valet tld test
Password:
Restarting dnsmasq...
Valet is configured to serve for TLD [.test]
Restarting php...
Restarting nginx...
Your Valet TLD has been updated to [test].
➜  ~ valet install
Stopping nginx...
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration...
Restarting php...
Restarting dnsmasq...
Valet is configured to serve for TLD [.test]
Restarting nginx...

Valet installed successfully!
➜  ~ ping foobar.test
ping: cannot resolve foobar.test: Unknown host

@drbyte Could you share the output of your brew services list so that I could compare with mine and see which ones should be run as root and which ones as user:

dnsmasq   started root   /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
[email protected] started tanmay /Users/tanmay/Library/LaunchAgents/[email protected]
nginx     started root   /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       started root   /Library/LaunchDaemons/homebrew.mxcl.php.plist
redis     started tanmay /Users/tanmay/Library/LaunchAgents/homebrew.mxcl.redis.plist

Those are normal.

brew services list
Name    Status  User  Plist
dnsmasq started root  /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mariadb started chris /Users/chris/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   started root  /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     started root  /Library/LaunchDaemons/homebrew.mxcl.php.plist
redis   started chris /Users/chris/Library/LaunchAgents/homebrew.mxcl.redis.plist

Ping isn't always reliable, depending on various configuration factors.
However, when dnsmasq is working correctly, you can see confirmation by using dig, which should show it resolving to the 127.0.0.1 localhost address:

dig foobar.test

; <<>> DiG 9.8.3-P1 <<>> foobar.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52759
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;foobar.test.           IN  A

;; ANSWER SECTION:
foobar.test.        0   IN  A   127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Nov 18 13:20:44 2018
;; MSG SIZE  rcvd: 45

This may be redundant to ask, but have you rebooted (so all the services reload their configs, after all these changes)?

ALSO, since you did the rename, perhaps the master /usr/local/etc/dnsmasq.conf still has reference to the old user? (I was hoping the valet install would at least add your new user. But maybe it's got both, and it's dying because it's not found?)
Related discussion: https://github.com/laravel/valet/issues/655

After you get it pointing to your own user's dnsmasq config it should work. If it doesn't, then you can enable logging by adding some logging directives to that file. I posted an example of a highly configured config at
https://github.com/laravel/valet/issues/115#issuecomment-241275816 -- you could add the 2 lines that start with "log" and then brew services stop dnsmasq && brew services start dnsmasq

ALSO, since you did the rename, perhaps the master /usr/local/etc/dnsmasq.conf still has reference to the old user?

Yes that was the case, later I removed/uncommented the one with the old user's reference:

# Comment this line:
# conf-file=/Users/OLD_USER_NAME/.config/valet/dnsmasq.conf

# Keep this line:

conf-file=/Users/NEW_USER_NAME/.config/valet/dnsmasq.conf

You may close the issue now.

Thanks for reporting back.
Since you opened the Issue, you can close it by clicking the Close button below. Thanks!

thanks @HerrEisenheim

Thanks, @HerrEisenheim! It worked for me on my second account!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomirons picture tomirons  Â·  4Comments

papakay picture papakay  Â·  3Comments

eberkund picture eberkund  Â·  4Comments

Flimm picture Flimm  Â·  5Comments

hsleewis picture hsleewis  Â·  5Comments