My Mac mini's computer name keeps changing when it resumes from sleep
I've seen this happen when the local DNS server has DNS caching enabled, but doesn't flush the cache often enough (or at all).
You can set your Host Name/Computer Name to a static value using scutil in Terminal. This means that your Mac will no longer change it's name automatically, so it's important that there are no other machines on your network that actually have that hostname. When you run this, replace "new_hostname" with your desired hostname:
sudo scutil --set HostName new_hostname sudo scutil --set LocalHostName new_hostname sudo scutil --set ComputerName new_hostname
You can check to make sure the values are set by running:
scutil --get HostName scutil --get LocalHostName scutil --get ComputerName
Usually this is the fault of the router and the Mac is responding to conditions out of its control.
Have you tried using a fixed IP address or making a DHCP reservation so that your Mac more reliably claims the same address when it wakes from sleep?
This has gotten much worse with iOS 8 and OS X 10.10 and there are several bugs in the new discoveryd daemon that replaces mDNSResponder for DNS naming and device discovery and routing. Basically, even computers with one network connection, there are two IP addresses - one IPv4 and the other IPv6 and the system is confusing one for the other and incrementing the host name.
This happens to me on occasion most typically when the OS has some sort of hiccup and needs a cold restart.
Unplug the router. For some reason after the restart, the computer has trouble connecting with the network as the, router "thinks" that a connection was never broken in the first place. Given a connection can't me made with the given username, the operation system adds a (1, 2, 3…) to the end of the name.
Restart the computer.
Go to preferences/Sharing and change the name of your computer from "Your Name's iMac (2)", to "Your Name's iMac"
Plug the router back in.
Connect to the network.
Worked for me!
Another option to try is disabling Wake for Network Access inside of System Preferences -> Energy Saver. We have this problem at work and doing that + renaming it back usually seems to hold the name in place
This automatic renaming hostname number
... suffix problem plagues many Apple devices, has a lot of potential workarounds, but no known full solution. It most likely has to do with a network discovery protocol used for Apple AirPlay and other services called:
mDNS(also known as
Avahito Linux users, or
Zero-confNetworking to Windows users).
This service is automatically started in Mac OSX, and is how local machines are able to discover each other via
hostname.local mDNS names, as well as discover services such as AirPlay.
Many users online have come up with workarounds or potential solutions, but in my experience none have worked reliably all the time. Setting hostname only appears to work for a short period.
I have started a Work-in-progress workaround & answer placeholder here. Hopefully Apple will provide a fix for this issue in the future!