# Unison, Socket Method, Connection refused



## Red52 (Aug 29, 2016)

Hello World,

Have used the unison socket method on Linux when security is not a concern (isolated network).  New to FreeBSD.  Two FreeBSD boxes.  Going either direction the connection is refused.  I have run out of ideas.


```
$ uname -a
FreeBSD stan3 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016  root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
```


```
uname -a
FreeBSD acer00 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016  root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
```

On one, as root,

```
unison -socket 55555
```

On the other, as root,

```
unison /usr/ports/distfiles socket://stan3:55555//usr/ports/distfiles
```

There are entries in both /etc/hosts files and ping functions in both directions.

Nothing has been added to either /etc/rc.conf pertaining to firewalls.

Thanks


----------



## SirDice (Aug 30, 2016)

A "Connection refused" usually means you're trying to connect to a socket that's closed. It's probably not a firewall issue as that usually results in a "Connection timed out". So make sure the first command actually opens a port, sockstat(1) is quite useful for this. As are tools like tcpdump(1) that will let you see the actual packets.


----------



## Red52 (Aug 30, 2016)

```
# unison -socket 55555
server started
```

sockstat seamed to show that IPv6 and not IPv4 was being used.


```
$ sockstat
USER  COMMAND  PID  FD PROTO  LOCAL ADDRESS  FOREIGN ADDRESS
```


```
$ sockstat |grep unison
root  unison  800  3  tcp6  *:55555  *:*
$ sockstat |grep 55555
root  unison  800  3  tcp6  *:55555  *:*
$
```

Tried adding `ipv6_activate_all_interfaces="NO"` near the top of /etc/rc.conf, no change.

More time will be spent on this later.


----------



## Red52 (Aug 31, 2016)

Solved by adding `-host <IP Address>`


```
# unison -host <IP Address> -socket 55555
server started
```


```
$ sockstat|grep 55555
root  unison  792  3  tcp4  <IP Address>:55555 *:*
$
```


```
$ unison -help|grep -i 'host xxx'
 -host xxx  bind the socket to this host name in server socket mode
```


----------



## kernel-of-truth (Sep 3, 2016)

This issue is similar to a snag I once encountered using mount_smbfs(8).
# Command to create local mount of remote share

```
~]# mount_smbfs -I <IPv4-address> \
> //<remote-username>@<remote-hostname>/<remote-share-name> \
> /mnt/<dir-mapped-to-remote-share>
```

# System prompt

```
Password: [<remote-username-password>
```

# Connection fails with message

```
mount_smbfs: unable to open connection: syserr = Connection reset by peer
```

# Solution
<remote-hostname> must be the hostname of the machine you're attempting to connect with.

If you use an IP address in place of a valid network hostname, it appears the local FreeBSD system interprets the first octet (of the IP) as the hostname of a fully-qualified name.

L


----------

