Fix your Mac’s network name getting (2) appended to it

NetworkIconXWhen you enable services like screen sharing, file sharing, or printer sharing, OS X will broadcast your Mac’s name on the local network so it can be discovered and made available to other systems. However, when you do so you may run into an issue where a number is appended to your Mac’s name. For example, if your iMac is named “My iMac,” you might expect to see just this name appear in the Finder of other Macs on the network; however, with this naming issue you will see “My iMac (2).”

This problem happens because of a naming conflict with Apple’s “Bonjour” networking services. When your Mac broadcasts its name, other systems on the network (including your Mac) will cache the name and have it recognized as a device on the network.

There are various reasons why naming conflicts may occur, but in general it happens when your Mac loses its connection to the network (such as by going to sleep) and when it reconnects, a misconfiguration results in it re-broadcast its name, detecting its name is already in use, and then resolving this issue by appending a unique number to its name.

There are several approaches you can take to fix this problem if it arises.

1. Edit the computer name

Sometimes this problem is from a single instance of a conflict that is otherwise resolved and will not repeat itself. In these cases, however, your Mac may maintain its new name until you change it manually. Therefore, first try simply renaming your Mac in the Sharing system preferences to the desired name. If your local network (Bonjour) name does not change as well, then be sure you change this by clicking the Edit button under the computer name, and updating it accordingly.

2. Ensure you have only one connection to the local network

Your Mac may have more than one active network connection, including multiple Ethernet and Wi-Fi ports. If more than one are active and connecting to the same network, then your Mac may be broadcasting its services more than once. Therefore, try disabling all but your main one in the Network system preferences (uncheck the unused ones). Then restart your Mac, rename it if needed, and see if the problem persists.

Network ports in OS X

Ensure your active network connections listed here are on different networks. This is especially true for multiple WiFi and Ethernet ports.

3. Turn Bonjour off and back on

By restarting the Bonjour networking service in OS X, you will force the system to reload its configuration. Granted this should be doable by restarting your system, but you can also specifically force the service to close and re-launch. First run the following command in the OS X Terminal, to force any instances of OS X’s network discovery service to restart (for OS X prior to Yosemite):

sudo killall mDNSResponder

To turn Bonjour off:

sudo launchctl unload -w /System/Library/LaunchDaemons/

To turn it back on:

sudo launchctl load -w /System/Library/LaunchDaemons/

For OS X Yosemite and later, the commands are the following:

sudo killall discoveryd
sudo launchctl unload -w /System/Library/LaunchDaemons/
sudo launchctl load -w /System/Library/LaunchDaemons/

4. Clear mdnsresponder cache and network request configurations

In addition to restarting the service, you can also try flushing the caches and requests that the Bonjour networking service uses to resolve clients. These are in essence its configuration options that you can clear out and have it rebuild when it next runs. Following these commands, run the above commands to restart the Bonjour networking services.

sudo discoveryutil mdnsflushcache
sudo discoveryutil mdnsrestartquestions
sudo discoveryutil mdnsrestartregistrations
sudo discoveryutil udnsflushcache
sudo discoveryutil udnsrestartquestions

5. Shut down and reset ALL networking hardware

Finally, this issue may be with other Macs and network-capable hardware than your own, including Apple TVs, AirPort devices, third-party Network Attached Storage (NAS) devices, and routers and switches. Start by shutting down all computing devices like Macs and Apple TVs. Then turn off and unplug your routers, switches, and other network infrastructure devices. Consider even resetting your networking hardware, though keep in mind this will likely require you to fully reconfigure it. Now turn everything back on, starting with your network hardware, then your Macs (especially the ones with the faulty names). After configuring their network names accordingly, turn on your Apple TVs and other devices that also use the network.

6 thoughts on “Fix your Mac’s network name getting (2) appended to it

  1. David Emery

    I had this problem on the Mini that runs OS X Server. Disabling the WiFi interface (so the wired ethernet is the only connection) fixed it. This is Yet Another Annoying Apple Bug that reflects poorly on Apple’s Software QA.

  2. mark leitch

    I may have this problem, sometimes the Wifi devices loose connection, however access to the network appears fine with the Wifi icon still displayed in the menu bar, what seems to fix it is turning the router off and on again, but what a pain that is, do you know?

  3. Kent

    I have this problem on my laptop – half the time it’s connected to a thunderbolt display and uses it’s network connection – but the other half of the time it’s just a laptop.
    As a result – I have two network connections enabled. I am in the habit of turning off wireless when connected to the thunderbolt to try and avoid this – but it still happens at times.

    Editing the name to remove the (2) fixes it until next time. It’s a pain however ! Would be great if Apple could realise that it’s the same machine and not automatically rename.

  4. B. Jefferson Le Blanc

    I’ve run into this from time to time and usually ignore it because it has no functional affect. It’s merely cosmetic as far as I can see. In the meantime, I checked my computer name, as you suggested, in the Network preferences; it was OK. But when I clicked on the Edit button, the number 2 was attached to the name. It was simple enough to remove. I had not known, until reading this article, what the difference was between the computer name and the name on the local network. Thanks for the tip.

  5. Francisco

    You Rule!!! This actually fixed the network discovery problems that I had in my MacBook, it was taking very long for it to “see” computer in t he network, and the HP network printers. This procedure fixed it, thanks a lot!!!

  6. Gilles Meyer

    Hi Topher, thanks for this interesting post.

    By chance, would you have some pointers to more documentation about Bonjour’s hostname renaming behavior in this case?

Comments are closed.