NFS connection refused

Hi, first time post here. I’m still getting the hang of linux and nixos so I really appreciate any help. Feel like I’m driving myself mad with this issue that feels like it should be fairly simple.

I’m attempting to set up an nfs share on a locally hosted nixos machine running 25.11, and I am unable to mount the share. All of the following were run on the server itself, but the same issues persist on the client machine I plan to use to access it. The crux of the issue is:

phoenix@phoenixmedia:~/ > sudo mount localhost:/ /mnt/test
mount.nfs: Connection refused for localhost:/ on /mnt/test

relevant configuration:

fileSystems.“/export/phoenixmedia” = {
  device = “/mnt/hdd/data/phoenixmedia”;
  options = [“bind”];
};

services.nfs = {
  server = {
    enable = true;
    createMountPoints = true;
    hostName = “phoenixmedia”;
    exports = ‘’
      /export *(rw,fsid=0,no_subtree_check)
      /export/phoenixmedia *(rw,nohide,fsid=0,insecure,no_subtree_check)
    ‘’;
    lockdPort = 4001;
    mountdPort = 4002;
    statdPort = 4000;
    extraNfsdConfig = ‘’‘’;
  };

I have the firewall turned off for testing purposes. But opened all the relevant ports anyway.

networking.firewall.enable = false;
networking.firewall.allowedTCPPorts = [ 111  2049 4000 4001 4002 20048 ];
networking.firewall.allowedUDPPorts = [ 111  2049 4000 4001 4002 20048 ];

exportfs output

phoenix@phoenixmedia:~/ > sudo exportfs
[sudo] password for phoenix:
/export         <world>
/export/phoenixmedia
                <world>

According to the logs, nfs appears to startup without issue:

Jan 23 15:45:56 phoenixmedia systemd[1]: Starting NFSv4 ID-name mapping service...
Jan 23 15:45:56 phoenixmedia systemd[1]: Starting NFS Mount Daemon...
Jan 23 15:45:56 phoenixmedia systemd[1]: Starting NFS status monitor for NFSv2/3 locking....
Jan 23 15:45:56 phoenixmedia rpc.idmapd[1043]: Setting log level to 0
Jan 23 15:45:56 phoenixmedia rpc.idmapd[1043]: libnfsidmap: Unable to determine the NFSv4 domain; Using 'localdomain' as the NFSv4 domain which means UIDs will be mapped to the 'Nobody-User' user defined in /etc/idmapd.conf
Jan 23 15:45:56 phoenixmedia rpc.statd[1044]: Version 2.7.1 starting
Jan 23 15:45:56 phoenixmedia rpc.statd[1044]: Flags: TI-RPC
Jan 23 15:45:56 phoenixmedia systemd[1]: Started NFSv4 ID-name mapping service.
Jan 23 15:45:56 phoenixmedia rpc.mountd[1049]: Version 2.7.1 starting
Jan 23 15:45:56 phoenixmedia rpc.statd[1044]: Running as root.  chown /var/lib/nfs to choose different user
Jan 23 15:45:56 phoenixmedia systemd[1]: Started NFS status monitor for NFSv2/3 locking..
Jan 23 15:45:56 phoenixmedia systemd[1]: Started NFS Mount Daemon.
Jan 23 15:45:56 phoenixmedia systemd[1]: Starting NFS server and services...
Jan 23 15:45:57 phoenixmedia kernel: NFSD: Using nfsdcld client tracking operations.
Jan 23 15:45:57 phoenixmedia kernel: NFSD: no clients to reclaim, skipping NFSv4 grace period (net f0000000)
Jan 23 15:45:57 phoenixmedia systemd[1]: Finished NFS server and services.
Jan 23 15:45:57 phoenixmedia systemd[1]: Starting Notify NFS peers of a restart...
Jan 23 15:45:57 phoenixmedia sm-notify[1072]: Version 2.7.1 starting
Jan 23 15:45:57 phoenixmedia systemd[1]: Started Notify NFS peers of a restart.

There is this this series of rpc logs that could be relevant?

Jan 23 15:45:47 phoenixmedia systemd[1]: Mounted RPC Pipe File System.
Jan 23 15:45:47 phoenixmedia systemd[1]: Reached target rpc_pipefs.target.
Jan 23 15:45:47 phoenixmedia systemd[1]: Starting NFSv4 Client Tracking Daemon...
Jan 23 15:45:47 phoenixmedia systemd[1]: RPC security service for NFS client and server was skipped because of an unmet condition check (ConditionPathExists=/etc/krb5.keytab).
Jan 23 15:45:47 phoenixmedia systemd[1]: Reached target NFS client services.
Jan 23 15:45:47 phoenixmedia systemd[1]: Reached target Preparation for Remote File Systems.
Jan 23 15:45:47 phoenixmedia systemd[1]: Reached target Remote File Systems.
Jan 23 15:45:47 phoenixmedia (rpcbind)[616]: rpcbind.service: Referenced but unset environment variable evaluates to an empty string: RPCBIND_OPTIONS
Jan 23 15:45:48 phoenixmedia systemd[1]: Started NFSv4 Client Tracking Daemon.
Jan 23 15:45:48 phoenixmedia systemd[1]: Finished Record System Boot/Shutdown in UTMP.
Jan 23 15:45:48 phoenixmedia systemd[1]: Started RPC Bind.

File permissions:

phoenix@phoenixmedia:/export/phoenixmedia/ > ls -la /export/
total 16
drwxr-xr-x   3 nobody nogroup 4096 Jan  1 16:00 .
drwxr-xr-x  20 root   root    4096 Jan  1 16:00 ..
drwxrws---+  5 nobody nogroup 4096 Jun 28  2025 phoenixmedia

I stumbled across this pr but havent been able to say for certain if this has anything to do with the problem. Despite all my investigation I still havent even been able to narrow it down to a client or a server problem, but my hunch tells me its the latter.

tyia

1 Like

Have you tried adding localhost to hostName like this hostName = "phoenixmedia,localhost";?

yep that worked! after playing whack a mole with a few other problems here is my working config.

  boot.supportedFilesystems = [ "nfs" ];

  fileSystems."/export/phoenixmedia" = {
    device = "/mnt/hdd/data/phoenixmedia";
    options = ["bind"];
  };

  services.nfs = {
    server = {
      enable = true;
      createMountPoints = true;
      exports = ''
        /export/phoenixmedia 10.0.0.22/24(rw,fsid=0,no_subtree_check)
     '';
      lockdPort = 4001;
      mountdPort = 4002;
      statdPort = 4000;
      extraNfsdConfig = '''';
    };
  };

Thanks for the help