peterldowns / localias

custom local domain aliases for local dev servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: failed to start mDNS server

baryla opened this issue · comments

When running localias with localias run, I'm getting an error that mDNS server cannot be started;

failed to start mDNS server:
could not determine host IP for .local domains: lookup Adrians-Macbook-Pro.local.local: no such host

When running $ hostname (on MacOS Sonoma 14.2.1), I'm getting in terminal: Adrians-Macbook-Pro.local.

I suspect the issue is from this line where it assumes that local is not already passed in:

baseIPs, err := net.LookupIP(baseHost + ".local")

I'd post a PR to only append .local if it doesn't already exist in the string but I'm not familiar with golang enough to contribute. Perhaps something like this could work:

userHost := baseHost

if strings.Contains(userHost, ".local") == false {
  userHost = userHost + ".local"
}

baseIPs, err := net.LookupIP(userHost)

Thanks for the bug report, and I’m sorry for the trouble. I’ll repro and fix sometime this week. This is probably affecting other people too, thank you again.

Just to help me debug, can you tell me what version of localias you’re running with localias version?

No worries at all. Thanks for taking the time to help and build this tool!

The version is: 2.0.1+commit.c358250. I only just installed it via brew yesterday.

^ I didn't mean to close this automatically, but I believe the issue is now fixed. I'm in the process of pushing up the new version to brew; I'll follow up here once you can upgrade and test to see if it fixes your problem.

@baryla if you brew upgrade localias, you should receive localias version 2.0.2+commit.56d660e, and it should correctly start the mDNS server. Please confirm, and if it works, close the issue. 🫡

@peterldowns I just closed #21, and I know I neglected to show you the log output, but I also had this issue and can confirm the new release has fixed the extra .local problem. Or at the very least, I see no error message anymore.

@taylorthurlow OK, based on your confirmation that you did indeed have this same problem, I'm going to mark this issue as closed.

@baryla if for some reason the fix didn't work for you, please re-open this issue.

@peterldowns just installed localias, and I encounter exactly this issue.

Versions:

  • OS: macOS 14.3.1
  • localias: 2.0.2+commit.56d660e

Terminal output:

➜ localias list
sveltekit.local -> 5173

~ 
➜ localias -v
2.0.2+commit.56d660e

~ 
➜ localias run
2024/03/20 22:28:25.076 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//127.0.0.1:2019", "//localhost:2019", "//[::1]:2019"]}
2024/03/20 22:28:25.076 INFO    tls.cache.maintenance   started background certificate maintenance      {"cache": "0x1400037b260"}
2024/03/20 22:28:25.077 INFO    http    server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2024/03/20 22:28:25.077 INFO    http    enabling automatic HTTP->HTTPS redirects        {"server_name": "srv0"}
2024/03/20 22:28:25.082 INFO    pki.ca.local    root certificate is already trusted by system   {"path": "storage:pki/authorities/local/root.crt"}
2024/03/20 22:28:25.082 INFO    tls     cleaning storage unit   {"description": "FileStorage:/Users/thomas/Library/Application Support/localias/caddy"}
2024/03/20 22:28:25.082 INFO    http    enabling HTTP/3 listener        {"addr": ":443"}
2024/03/20 22:28:25.082 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/03/20 22:28:25.082 INFO    http.log        server running  {"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2024/03/20 22:28:25.082 INFO    http    enabling automatic TLS certificate management   {"domains": ["sveltekit.local"]}
2024/03/20 22:28:25.082 INFO    tls     finished cleaning storage units
failed to start mDNS server:
could not determine host IP for .local domains: lookup thdg_mbp.local: no such host
daemon: listening for rpc requests

@distinctgrey very weird, I haven't seen this failure where the current host cannot be found over mdns. Can you try killing any mdnsresponder processes with kill -9 and trying again?

# show existing processes
ps aux | grep -i mDNSResponder
# kill
sudo pkill -9 mDNSResponder
# confirm that the process restarted successfully, has a new pid
ps aux | grep -i mDNSResponder

I'm not on macOS 14, and unfortunately I can't reproduce this problem. Is there any way in which you know you're doing something weird with your /etc/hosts or /etc/resolv.conf or your network settings? Is it possible you're connected to a corporate VPN of some sort?

I'm grasping at straws, sorry, I really don't know what's wrong here. I'll push a "fix" that turns this into a clearer warning, and explains that without the dns server requests to *.local will be subject to macOS-induced delays like I wrote above.

@distinctgrey did restarting mDNSResponder fix the problem? Do you have any more information you can share about your networking setup? If you run hostname, what is the output?