# nfsd bails out: address already in use

## schnabelvieh

Dear all,

I'm trying to bring up my nfs-server again. Unfortunately the nfsd daemon refuses to start and leaves the following syslog message:

Sep  3 19:14:25 localhost rpc.statd[6356]: Version 1.0.6 Starting

Sep  3 19:14:25 localhost nfsd[6372]: nfssvc: Address already in use

Sep  3 19:14:25 localhost rc-scripts: Error starting NFS daemon

Mmm, I'm a really kind of clueless. I've tried running rpc.nfsd manually using a different port than the default 2049er, but things did not change.

The kernel is a freshly compiled (make clean && make) 2.6.17-gentoo-r7, nfs v3 btw.  I've tried both nfsd as module and included into the kernel. nfs-util was recompiled several times, portmap is working, rpcinfo doesn't list 2049 as already in use.

Please help me out,

schnabelvieh 

P.S.: The client complains about a nonreadable superblock of the share, which is impossible, cause my share is mounted and very well accesable on the nfs-server itself .....   :Sad: 

----------

## Wechner

I'm experiencing here exactly the same problem on my server. Going back to kernel version 2.6.15 which I was using before solves it again. The config, the progs, the exports, ... nothing has changed, only the kernel.

Has noone an idea?

----------

## Wechner

Here is an strace of a manual call to /usr/sbin/rpc.nfsd 8 (which issued the same log entry as above):

```
execve("/usr/sbin/rpc.nfsd", ["/usr/sbin/rpc.nfsd", "8"], [/* 39 vars */]) = 0

brk(0)                                  = 0x804b000

access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)

open("/etc/ld.so.cache", O_RDONLY)      = 3

fstat64(3, {st_mode=S_IFREG|0644, st_size=21242, ...}) = 0

mmap2(NULL, 21242, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f40000

close(3)                                = 0

open("/lib/libc.so.6", O_RDONLY)        = 3

read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320Y\1"..., 512) = 512

fstat64(3, {st_mode=S_IFREG|0755, st_size=1234588, ...}) = 0

mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f3f000

mmap2(NULL, 1173116, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e20000

mmap2(0xb7f38000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x117) = 0xb7f38000

mmap2(0xb7f3c000, 9852, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f3c000

close(3)                                = 0

mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e1f000

set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e1f6b0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0

mprotect(0xb7f38000, 8192, PROT_READ)   = 0

mprotect(0xb7f60000, 4096, PROT_READ)   = 0

munmap(0xb7f40000, 21242)               = 0

brk(0)                                  = 0x804b000

brk(0x806c000)                          = 0x806c000

open("/etc/nsswitch.conf", O_RDONLY)    = 3

fstat64(3, {st_mode=S_IFREG|0644, st_size=503, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7dff000

read(3, "# /etc/nsswitch.conf:\n# $Header:"..., 131072) = 503

read(3, "", 131072)                     = 0

close(3)                                = 0

munmap(0xb7dff000, 131072)              = 0

open("/etc/ld.so.cache", O_RDONLY)      = 3

fstat64(3, {st_mode=S_IFREG|0644, st_size=21242, ...}) = 0

mmap2(NULL, 21242, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f40000

close(3)                                = 0

open("/lib/tls/i686/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/tls/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/i686/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/libnss_db.so.2", O_RDONLY)   = -1 ENOENT (No such file or directory)

open("/usr/lib/tls/i686/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/tls/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/i686/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/libnss_db.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)

munmap(0xb7f40000, 21242)               = 0

open("/etc/ld.so.cache", O_RDONLY)      = 3

fstat64(3, {st_mode=S_IFREG|0644, st_size=21242, ...}) = 0

mmap2(NULL, 21242, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f40000

close(3)                                = 0

open("/lib/libnss_files.so.2", O_RDONLY) = 3

read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260\33"..., 512) = 512

fstat64(3, {st_mode=S_IFREG|0755, st_size=35292, ...}) = 0

mmap2(NULL, 37520, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e15000

mmap2(0xb7e1d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7) = 0xb7e1d000

close(3)                                = 0

munmap(0xb7f40000, 21242)               = 0

open("/etc/services", O_RDONLY)         = 3

fcntl64(3, F_GETFD)                     = 0

fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0

fstat64(3, {st_mode=S_IFREG|0644, st_size=35842, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7df5000

read(3, "# /etc/services\n#\n# Network serv"..., 131072) = 35842

close(3)                                = 0

munmap(0xb7df5000, 131072)              = 0

chdir("/var/lib/nfs")                   = 0

open("/dev/null", O_RDWR|O_LARGEFILE)   = 3

dup2(3, 0)                              = 0

dup2(3, 1)                              = 1

dup2(3, 2)                              = 2

open("/proc/self/fd", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4

fstat64(4, {st_mode=S_IFDIR|0500, st_size=0, ...}) = 0

fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0

getdents64(4, /* 7 entries */, 1024)    = 168

getdents64(4, /* 0 entries */, 1024)    = 0

close(4)                                = 0

open("/proc/fs/nfsd/versions", O_WRONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)

open("/proc/fs/nfsd/portlist", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)

open("/proc/fs/nfsd/threads", O_WRONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)

open("/proc/fs/nfs/threads", O_WRONLY|O_LARGEFILE) = 4

write(4, "8\n", 2)                      = -1 EADDRINUSE (Address already in use)

close(4)                                = 0

time(NULL)                              = 1158021901

open("/etc/localtime", O_RDONLY)        = 4

fstat64(4, {st_mode=S_IFREG|0644, st_size=2295, ...}) = 0

fstat64(4, {st_mode=S_IFREG|0644, st_size=2295, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7df5000

read(4, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\10\0"..., 131072) = 2295

close(4)                                = 0

munmap(0xb7df5000, 131072)              = 0

stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2295, ...}) = 0

stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2295, ...}) = 0

stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2295, ...}) = 0

getpid()                                = 17564

socket(PF_FILE, SOCK_DGRAM, 0)          = 4

fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0

connect(4, {sa_family=AF_FILE, path="/dev/log"}, 110) = -1 EPROTOTYPE (Protocol wrong type for socket)

close(4)                                = 0

socket(PF_FILE, SOCK_STREAM, 0)         = 4

fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0

connect(4, {sa_family=AF_FILE, path="/dev/log"}, 110) = 0

send(4, "<27>Sep 12 02:45:01 nfsd[17564]:"..., 64, MSG_NOSIGNAL) = 64

close(4)                                = 0

exit_group(1)                           = ?

Process 17564 detached
```

I really got desperate now, as I am not able to determine what goes wrong here ...

----------

## Wechner

Hello.

I finally found a solution that solved it for me here. The DHCP component of my dnsmasq was running on port 2048. I shut down dnsmasq, started nfsd and started dnsmasq again and everything is working again now. Also after a reboot, it works.

Hope this helps.

- Wechner

----------

## tekknokrat

Hm, I know this threads way old but I also have this kind of problem with nfs!

When I rc-update nfs to default runlevel its not started correctly on boot with this message in syslog:

```
Apr  4 17:11:52 homeserver nfsd[6250]: nfssvc: Address already in use

Apr  4 17:11:52 homeserver rc-scripts: Error starting NFS daemon

```

and with this in netstat -an:

```

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address           Foreign Address         State

tcp        0      0 *:6600                  *:*                     LISTEN

tcp        0      0 *:sunrpc                *:*                     LISTEN

tcp        0      0 *:ssh                   *:*                     LISTEN

tcp        0      0 *:2204                  *:*                     LISTEN

tcp        0      0 *:927                   *:*                     LISTEN

tcp        1      0 localhost:2916          localhost:6600          CLOSE_WAIT

tcp        0      0 localhost:6600          localhost:2916          FIN_WAIT2

tcp        0    128 homeserver.lan:ssh      gentoo.lan:55605        ESTABLISHED

udp        0      0 *:2048                  *:*

udp        0      0 *:904                   *:*

udp        0      0 *:924                   *:*

udp        0      0 *:bootpc                *:*

udp        0      0 *:sunrpc                *:*

Active UNIX domain sockets (servers and established)

Proto RefCnt Flags       Type       State         I-Node Path

unix  2      [ ACC ]     STREAM     LISTENING     6555   /var/run/sdp

unix  2      [ ]         DGRAM                    7279   /var/run/hostapd/ath0

unix  2      [ ACC ]     STREAM     LISTENING     6217   /dev/log

unix  2      [ ]         DGRAM                    1269   @/org/kernel/udev/udevd

unix  2      [ ACC ]     STREAM     LISTENING     6353   /var/run/dbus/system_bus_socket

unix  3      [ ]         STREAM     CONNECTED     8482

unix  3      [ ]         STREAM     CONNECTED     8481

unix  3      [ ]         STREAM     CONNECTED     8163   /var/run/sdp

unix  3      [ ]         STREAM     CONNECTED     8162

unix  3      [ ]         STREAM     CONNECTED     8159   /dev/log

unix  3      [ ]         STREAM     CONNECTED     8158

unix  3      [ ]         STREAM     CONNECTED     7876   /dev/log

unix  3      [ ]         STREAM     CONNECTED     7875

unix  3      [ ]         STREAM     CONNECTED     7848

unix  3      [ ]         STREAM     CONNECTED     7847

unix  3      [ ]         STREAM     CONNECTED     7134   /dev/log

unix  3      [ ]         STREAM     CONNECTED     7133

unix  3      [ ]         STREAM     CONNECTED     6528   /dev/log

unix  3      [ ]         STREAM     CONNECTED     6527

unix  3      [ ]         STREAM     CONNECTED     6493   /var/run/dbus/system_bus_socket

unix  3      [ ]         STREAM     CONNECTED     6492

unix  3      [ ]         STREAM     CONNECTED     6471   /dev/log

unix  3      [ ]         STREAM     CONNECTED     6470

unix  3      [ ]         STREAM     CONNECTED     6356

unix  3      [ ]         STREAM     CONNECTED     6355

```

After boot on  

```
/etc/init.d/nfs restart
```

 it works without probs!

on my other boxes with same gentoo/kernel/nfs-util release it runs without problem, already on start.

----------

## nick_smith

Hi,

I know this thread is old now but I've just been having the same problem. 

```
netstat -anp
```

 showed that rpc.mountd had hold of port 2049 thus stoppping nfs from starting.

Having been messing around with this for a while, the solution was ultimately very simple: I edited /etc/conf.d/nfs to contain the line 

```
OPTS_RPC_MOUNTD="-p 32767"
```

 (which is actually there already but commented out).

A similar line exits for rpc.statd (OPTS_RPC_STATD) if that's what hogging port 2049 on your system

----------

