Skip to content

Instantly share code, notes, and snippets.

@sboorlagadda
Created April 12, 2019 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sboorlagadda/150d6700c5a0df6b814d3712ac040d80 to your computer and use it in GitHub Desktop.
Save sboorlagadda/150d6700c5a0df6b814d3712ac040d80 to your computer and use it in GitHub Desktop.
Why is my hostname resolution taking so long?
I was able to fix this issue by explicitly setting the HostName using scutil to be the same value as LocalHostName:
$ scutil --set HostName $(scutil --get LocalHostName)
Now:
$ sudo scutil --set HostName MacBook-Pro
$ time python -c 'import socket; print(socket.getfqdn())'
MacBook-Pro
python -c 'import socket; print(socket.getfqdn())' 0.01s user 0.00s system 86% cpu 0.016 total
I was confused before because of the following:
$ scutil --get LocalHostName
MacBook-Pro
$ hostname
MacBook-Pro.local
But:
$ scutil --get HostName
HostName: not set
https://apple.stackexchange.com/questions/175320/why-is-my-hostname-resolution-taking-so-long
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment