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

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

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.

Photo of author


Mac Issues

At Mac Issues, we're dedicated to helping you learn how to use your Macbook properly. With tutorials, how-to troubleshooting guides & real reviews, hopefully we can make your day that little bit easier.

Read more from Mac Issues