“Connection failed”, when conneting to Avahi advertised Samba-service from OSX Finder

logo_samba.biu7haidj74s00w808s8kcoc4.17ldmg3f9ou8088wk04c40sgo.thIf you own a Mac and have recently tried advertising a Samba-service/share (most likely from a computer running Linux or a NAS-server), you properly also ran into the same problems that I were having, when trying to connect to it from the OSX Finder.

It seems the way that newer versions of OSX automatically discover Samba-services, changed at some point.

The old-fashioned configuration that DOES NOT work

In the “good ol’ days”, advertising a Samba-service from a Linux-based server (in my case, a Debian-server), involved something as simple as installing the “avahi” package with “aptitude” and afterwards creating the file “/etc/avahi/services/samba.service”, with the following content.

<?xml version="1.0" standalone='no'?>
<!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>139</port>
  </service>
</service-group>

With the above configuration, the Samba-service gets advertised to clients on the network. At first glance, OSX’s Finder also seems to discover the Samba-service, but when trying to connect, the following error-message gets displayed.

The configuration that DOES work

As I mentioned earlier, newer versions of OSX discovers Samba-services slightly different. Apparently the port-number changed from “TCP 139” to “TCP 445” as shown here, in the alternative configuration of the “samba.services”-file.

<?xml version="1.0" standalone='no'?>
<!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=Xserve</txt-record>
  </service>
</service-group>

As soon as I change to the above configuration, OSX Finder connected immediately and flawlessly. No need to restart the Avahi-service.

On a side note, the last “<service>”-block in the above configuration is purely aimed at OSX clients. It seems to advertises the Samba-service as being hosted by an Apple “Xserve”-computer, and so it changes the icon of the discovered Samba-service in OSX’s Finder sidebar.

Discovering advertised Samba-services in Windows

As this is the first time I’ve tried advertising my Samba-service with Avahi, I found that it is also relatively simple to get Windows-clients to discover the service automatically.

When installing the program “Bonjour Print Services for Windows” made by Apple, my Windows 7 computer also discovered the Samba-service through Windows explorer.

You might be wandering about configuring your firewall, but according to this link “http://support.apple.com/kb/dl999” (which is also where you can download the program mentioned above), installing the program also takes care of that for you.

Resources used

A forum-post by user “Nezil”: http://lime-technology.com/forum/index.php?topic=14623.0

“Bonjour Print Services for Windows”: http://support.apple.com/kb/dl999

Get printer-friendly version

4 thoughts on ““Connection failed”, when conneting to Avahi advertised Samba-service from OSX Finder”

    1. Hey Tim. I’m glad it helped you out.

      However I’m not completely sure I understand the problem you ran into, when using my XML sample. Maybe you could explain it to me, before I decide to make any changes to the article?

      As an example, i tried copying my own XML sample and pasting it into a new document using the nano command line text editor, both in OS X as well as in Linux. Here I saw no evidence of converted/corrupted characters.

Leave a reply