Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

mount.nfs: access denied by server while mounting an NFS share on Ubuntu

Errormount.nfs: access denied by server while mounting server:/srv

Short answer

The NFS server refuses a client that its /etc/exports file does not allow. Add the client's address to that export line with no space before the option list, reload the exports with exportfs -ra, and if the client connects from a port above 1023 add the insecure option.

  • Applies to nfs-kernel-server, nfs-common, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    On the server, list what is exported right now and to whom.

    sudo exportfs -v
  2. 2Match what you see, then jump to its fix

    1. 1exportfs -v shows the path but not your client's address or networkThe client is not listed in /etc/exportsFix
    2. 2The right line is in /etc/exports, but exportfs -v does not show itThe exports file was edited but never reloadedFix
    3. 3exportfs -v lists the path with options but the client you wrote is not restricted as you expectedA space separates the client from its optionsFix
    4. 4The client is listed correctly, but it is behind NAT or a tool that does not use a privileged source portThe client connects from a port above 1023Fix

What does the error look like?

  • mount.nfs: access denied by server while mounting server:/srv

Cause 1 of 4

The client is not listed in /etc/exports

1Check

Each line lists the clients allowed to mount the file system. Hosts can be a name, an IP address or a network with a netmask. Find the client's IP and compare.

cat /etc/exports
# on the client
hostname -I

2Fix

Add the client's IP or network to the export line.

/srv 192.168.1.0/24(rw,sync,no_subtree_check)

3Verify

Apply the change on the server, then mount again from the client.

sudo exportfs -ra
sudo mount server:/srv /mnt

Confirmed by man7.org

Did this fix it?

Cause 2 of 4

The exports file was edited but never reloaded

1Check

Changes to the file take effect only after exportfs -ra is run or the NFS server is restarted.

sudo exportfs -v

2Fix

Reload the exports.

sudo exportfs -ra

3Verify

The export now shows up in the listing.

sudo exportfs -v

Confirmed by man7.org

Did this fix it?

Cause 3 of 4

A space separates the client from its options

1Check

No whitespace is permitted between a client and its option list. Look for a space before the opening parenthesis.

grep -n ' (' /etc/exports

2Fix

Remove the space so the options belong to the client.

# wrong
/srv 192.168.1.0/24 (rw,sync)
# right
/srv 192.168.1.0/24(rw,sync)

3Verify

Reload and check the listing.

sudo exportfs -ra
sudo exportfs -v

Confirmed by man7.org

Did this fix it?

Cause 4 of 4

The client connects from a port above 1023

1Check

secure is the default and requires requests to come from a port below 1024. Clients that cannot do that are refused.

sudo exportfs -v | grep -i secure

2Fix

Add insecure to the export options, only if you accept that trade-off for this client.

/srv 192.168.1.0/24(rw,sync,no_subtree_check,insecure)

3Verify

Reload and mount again.

sudo exportfs -ra
sudo mount server:/srv /mnt

Confirmed by man7.org

Did this fix it?

How do I stop it coming back?

  • Export to a network or a fixed address, not to a name that may resolve differently.
  • Run exportfs -ra after every edit of /etc/exports.
  • Install nfs-common on every client before the first mount attempt.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.