I have just updated my Mac to macOS Sierra 10.12. My hostname is ninjaPixels-Macbook-Pro and if I run:
ping ninjaPixels-Macbook-Pro.local
or ping ninjaPixels-Macbook-Pro
I get an error of unknown host.
host ninjaPixels-Macbook-Pro.local
returns the error: Host ninjaPixels-Macbook-Pro.local not found: 3(NXDOMAIN)
This is an issue as part of our codebase at work needs to run the following python: socket.gethostbyname(socket.gethostname())
and it fails because my computer seems to have forgotten who it is.
I can successfully run ping localhost
and ping 127.0.0.1
I’ve tried the following:
- Rebooting.
- Switching off the Firewall.
- Changing my local hostname, using System Preferences > Sharing > Edit.
sudo killall -HUP mDNSResponder
dscacheutil -flushcache
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
::1 127.0.0.1
instead seems to fix it.ping $HOSTNAME
. On a clean install of macOS Sierra, Firewall turned off and nothing shared, I can replicate aping $HOSTNAME
error. It I turn on, e.g. File Sharing, I canping $HOSTNAME
from macOS andping macOShostname.local
from OS X on the same network.