MacOS – Mavericks cannot connect to windows share by computer name, but works fine with IP

file-sharingfindermacosNetworkwindows

I have a Mac Mavericks and a Windows 7 machines.
On my Windows I have shared some folders, but I can only connect to them using the IP address, but not the computer name.

So Finder -> Go-> Connect to Server… and the smb://my-win/Share does not work, but Finder -> Go -> Connect to Server… and the smb://192.168.1.3/Share works perfectly fine.

If I go into Network (Finder -> Go -> Network), the computer my-win shows up. After I connected to the IP another windows machine shows up with the IP as the name. Going into the IP-named machine works fine again, while going into MY-WIN gives the same error

The error I get is:

There was a problem connecting to the server “my-win”.
The server may not exist or it is unavailable at this time. Check the server name or IP address, check your network connection, and then try again.

I have tried disabling firewalls which did not help. I have also tried renaming ~/Library/Preferences/com.apple.loginitems.plist. That did not solve the issue but made my-win disappear from the Network window, so I reverted it again

I can ping the IP of the windows machine but if I execute ping my-win I get an error saying: cannot resolve my-win: Unknown host

It seems like my Mac gets notified of the Windows computer name, but can't resolve it when it tries to. Does anybody know what could be the reason for this?

Best Answer

It is likely a name resolution issue, which is usually the case when an IP address works and a name does not.

there are a couple of things you can do

  1. if the PCs have IP addresses that rarely, or never, change you could add those to the hosts file. Just open up the terminal.app and:

sudo nano /private/etc/hosts

After the last entry just put the IP addresses of the PCs in there like this:

192.168.x.x pc-one

192.168.x.x pc-two

(substituting the IP addresses of the PCs for what you have) then save and exit. You'll want to flush the DNS cache. I usually just reboot but there are terminal commands depending on your OS version.

  1. If you don't mind installing some Apple software on your PC, Bonjour is part of the iTunes install and will automatically register names on the local network.

It is unlikely that it is a firewall issue as you can connect via IP. The firewall would block that too.

Also if you give it time any computers that the Mac can connect to (in recent OS versions) will show up in the Finder's sidebar. Bonjour will help with that.

You can also add the IP addresses of all your PCs in the connect to server dialog box, enter in the ip address and click the + button before you click connect. It ain't intuitive but it's better than nothing... ;-)