mount.nfs: access denied by server while mounting an NFS share on Ubuntu
mount.nfs: access denied by server while mounting server:/srvShort 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.
Fix it fast
1Find out which cause you have
On the server, list what is exported right now and to whom.
sudo exportfs -v2Match what you see, then jump to its fix
- 1
exportfs -v shows the path but not your client's address or networkThe client is not listed in /etc/exportsFix - 2
The right line is in /etc/exports, but exportfs -v does not show itThe exports file was edited but never reloadedFix - 3
exportfs -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
The 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
- 1
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 -I2Fix
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 /mntConfirmed by man7.org
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 -v2Fix
Reload the exports.
sudo exportfs -ra3Verify
The export now shows up in the listing.
sudo exportfs -vConfirmed by man7.org
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/exports2Fix
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 -vConfirmed by man7.org
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 secure2Fix
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 /mntConfirmed by man7.org
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix