How to Fix NFS Mount Failed and Connection Refused in Ubuntu

The error message “mount.nfs: Connection refused” or “mount.nfs: access denied by server while mounting” occurs in Ubuntu when a client system attempts to mount a remote Network File System (NFS) export and the request is blocked by unconfigured export permissions, a disabled NFS kernel server daemon, closed firewall ports, or missing RPC portmapper services. Because NFS relies on Remote Procedure Calls (RPC) across multiple dynamic ports, any firewall barrier or hostname mismatch between server and client severs the mount pipeline. Resolving this issue involves verifying NFS export syntax, enabling RPC services, and opening designated firewall ports.

Understanding Why NFS Mounts Fail

NFS operates over a suite of protocol daemons coordinated by the kernel. The server runs nfs-server (or nfs-kernel-server), which consults /etc/exports to determine which client IP subnets have permission to mount designated directories. When a client initiates a mount command (e.g., mount -t nfs 192.168.1.50:/srv/nfs /mnt/nfs), it must first communicate with rpcbind on port 111 before negotiating with the mount daemon (mountd) and the NFS server daemon on port 2049.

The most common failure points include:

  • Server Daemon Stopped: The nfs-kernel-server service on the host is inactive or crashed.
  • Unapplied Export Directives: Changes made to /etc/exports have not been re-exported into the kernel table using exportfs -ra. For related system mount errors, see our guide on fixing failed to mount /etc/fstab in Ubuntu.
  • Firewall Blocking RPC Ports: UFW or iptables on the server blocking TCP/UDP ports 111, 2049, or dynamic mountd ports.
  • Subnet / IP Mismatch: The client’s current IP address does not match the subnet mask declared in the server’s export line.
Error Message Root Mechanism Target Fix
Connection refused NFS daemon stopped or firewall blocking port 2049/111 Start nfs-kernel-server and open UFW NFS profile
Access denied by server Client IP not authorized in /etc/exports Add client IP/CIDR and execute exportfs -ra
No route to host Physical network disconnection or routing failure Verify ping connectivity and gateway routes
Protocol not supported NFS version mismatch (e.g., NFSv3 vs NFSv4) Explicitly pass -o nfsvers=4 in mount command

Step 1: Verify NFS Packages and Server Status

Ensure that both the server and client machines have the appropriate NFS utilities installed and active.

On the Ubuntu Client Machine

  1. Open the terminal (Ctrl + Alt + T).
  2. Install the common client utilities:
sudo apt update
sudo apt install nfs-common

On the Ubuntu Server Machine

  1. Ensure the NFS kernel server is installed and running:
sudo apt install nfs-kernel-server
sudo systemctl enable --now nfs-kernel-server
sudo systemctl status nfs-kernel-server

If the service status is inactive or failed, restart it with sudo systemctl restart nfs-kernel-server.

Step 2: Check Available Server Exports via showmount

Before attempting to mount, test from the client whether the remote NFS host is actively broadcasting its exported directories:

  1. From the client terminal, run showmount against the server’s IP address:
showmount -e 192.168.1.50
  1. Review the output:
    • If it outputs the export list (e.g., /srv/share 192.168.1.0/24), your network and firewall are working, but export permissions need adjustment.
    • If it returns Connection refused or times out, the firewall on the server is blocking RPC requests or the NFS daemon is offline.

Step 3: Correct /etc/exports Permissions on the Server

NFS is extremely strict regarding syntax in /etc/exports. Any space between the client IP definition and the bracketed options breaks permission parsing.

  1. On the NFS server, open the exports file:
sudo nano /etc/exports
  1. Ensure the export entry follows this exact syntax (note: no space between the IP/subnet and the opening bracket):
/srv/nfs_share 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)
  1. Save and exit (Ctrl + O, Enter, Ctrl + X).
  2. Apply the new exports table to the running kernel without restarting the server:
sudo exportfs -rav

The -r flag re-exports all directories, -a covers all entries, and -v displays verbose confirmation of exported paths.

Step 4: Configure UFW Firewall Rules for NFS

Ubuntu’s Uncomplicated Firewall (UFW) frequently blocks incoming RPC portmapper traffic unless specifically permitted.

  1. On the NFS server, check UFW status:
sudo ufw status
  1. If UFW is active, allow traffic from your local subnet to the NFS service:
sudo ufw allow from 192.168.1.0/24 to any port nfs
sudo ufw allow 111/tcp
sudo ufw allow 111/udp
sudo ufw allow 2049/tcp
sudo ufw allow 2049/udp
  1. Reload the firewall:
sudo ufw reload

Step 5: Test the Mount with Explicit Version Parameters

Modern Linux servers default to NFSv4, which does not require legacy RPC portmapper daemons, while older network appliances may only support NFSv3. Explicitly specifying the version avoids protocol mismatches.

  1. On the client machine, create the local mount directory:
sudo mkdir -p /mnt/nfs_share
  1. Mount using NFSv4 explicitly:
sudo mount -t nfs -o nfsvers=4 192.168.1.50:/srv/nfs_share /mnt/nfs_share
  1. If NFSv4 fails, test with NFSv3:
sudo mount -t nfs -o nfsvers=3 192.168.1.50:/srv/nfs_share /mnt/nfs_share
  1. Verify that the mount is active by inspecting disk usage:
df -hT /mnt/nfs_share

The output will confirm the remote share is mounted with the correct filesystem type, ready for reliable read and write operations.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.