19

When I wake my Mac mini from sleep, it occasionally comes up with a dialog saying "The name of your computer "whatever" is already in use on this network. The name has been changed to "whatever (1)"" (or (2), I'm up to (4) at the moment).

The Mac is plugged in to the network via an ethernet cable and gets a DHCP assigned IP address from my router which runs pfSense. I have DHCP set to give the same IP address to the Mac's Mac.

Why does this happen, and more usefully, how can I make the machine stop renaming itself?

In System Preferences - Sharing I have 'File sharing' and 'Remote Login' enabled.

2
  • I did the steps that Jon Flaire suggested, and the LocalHostName keeps reverting back, in my case from Tori to Tori(10). Any other ideas? This is driving me bonkers.
    – DJFriar
    Commented Oct 28, 2014 at 17:12
  • @DJFriar The same thing is happening to me. Might have started after installing Yosemite. FWIW I'm running an Airport Base Extreme with DHCP and another one (bridged) and 3 Airport Expressed (all bridged). Commented Oct 31, 2014 at 2:08

5 Answers 5

3

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.

3
  • No when I have this the IP stays the same but the name changes
    – mmmmmm
    Commented Jan 11, 2014 at 22:26
  • @Mark - The IP address is allocated based upon the MAC address of the sender of the DHCP request. It's still possible the router could be to blame - but it doesn't have to be as you commented.
    – bmike
    Commented Jan 11, 2014 at 23:34
  • true - bit this answer says make the Mac claim the same IP address and that definitely is not the issue I see
    – mmmmmm
    Commented Jan 12, 2014 at 0:44
11

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 

Sources: man scutil

https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/scutil.8.html

http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/

2

This happens to me on occasion most typically when the OS has some sort of hiccup and needs a cold restart.

  1. 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.

  2. Restart the computer.

  3. Go to preferences/Sharing and change the name of your computer from "Your Name's iMac (2)", to "Your Name's iMac"

  4. Plug the router back in.

  5. Connect to the network.

Worked for me!

1
  • 1
    This is fine for small networks. What happens when you have several Apple TV, three routers and 10 iOS devices? The corrupted name seems to propagate and be made worse my different sleep/wake cycles. This is a viable solution for small networks in an apartment or with few Apple devices. +1 for the solution, but I wanted to caution that this isn't viable for many business or larger networks.
    – bmike
    Commented Mar 27, 2015 at 13:39
0

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

0

This automatic renaming hostname number (1), (2), (N), ... 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:

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .