9

I am trying to mount a Directory from my server to my local machine. This is because I want to edit the directory and execute the files without having the manually push the files to the server after each edit.

I am using NFS and currently getting: 'Connection refused' when I try to mount from a machine on the same network.

My server ip is 192.168.0.12.
My local machine ip is 192.168.0.2. And in /etc/exports I have:

/mnt/export 192.168.0.0/24(rw,async,no_subtree_check)
/mnt/export *(rw)

where /mnt/export is the directory I want to mount and I have chmod 777 -r the directory

On my local machine I execute this command:

mount 192.168.0.12:/mnt/export /Desktop/tes

But get this error:

can't mount /mnt/export from 192.168.0.12 onto /Desktop/tes:
Connection refused

Does anyone have any idea to where I am going wrong?

5
  • You sure the service is started?
    – daisy
    Commented Jan 15, 2013 at 10:37
  • 1
    @warl0ck Thanks for the reply. Yes. When I run "exportfs" it gives me: /mnt/export 192.168.0.0/24 /mnt/export <world> which I assume is normal?
    – Phorce
    Commented Jan 15, 2013 at 10:39
  • firewalling? maybe
    – maniat1k
    Commented Jan 15, 2013 at 11:35
  • This might help nfs
    – max
    Commented Jan 27, 2015 at 17:27
  • If you are a RHEL user than have a look on this LINK
    – Manoj Sahu
    Commented Apr 28, 2017 at 7:07

7 Answers 7

5

You can test some of this from the client side. rpcinfo is useful to tell you if rpc calls are making it to the server processes, then you can check mountd specifically, and lastly, showmount will ask the server what volumes are exported:

$ rpcinfo -p nfsserv103 | cut -c30- | sort -u
 mountd
 nfs
 nlockmgr
 portmapper
 rquotad
 status

$ rpcinfo -u nfsserv103 mountd
program 100005 version 1 ready and waiting
program 100005 version 2 ready and waiting
program 100005 version 3 ready and waiting

$ showmount -e nfsserv103 
Export list for nfsserv103:
/                     10.221.253.101,10.221.252.101,10.221.253.100,10.221.252.100
/mnt_foo/bar         (everyone)

(note that "cut" in the first command was just to make the output more concise. you can drop off everything but the first command.)

2
  • Additionally, you can use tcpdump to capture the nfs traffic and see what is happening. So for a firewall, you'll see no server response. Or maybe you'll see a mountd refusal because the client request comes from a non-priviledged port, etc....
    – Tim B
    Commented Jan 15, 2013 at 12:40
  • The showmount has to be run as root
    – Egret
    Commented May 13 at 12:56
3

I had this problem on a machine running a standard Ubuntu 14.04 install.

The connection refused message can be misleading: It turns out that all that was required was to install the nfs-common package.

1
  • And rpcbind package as well
    – Mikolasan
    Commented May 17, 2022 at 23:39
2

A firewall is preventing the client from reaching the server. At this stage, you can't know whether NFS is configured properly (so it may well be): the client can't even see that there is an NFS server.

The most likely location for a firewall is the server. Check that it allows incoming connections on port 111 (rpc) and 2049 (nfs). On a Linux machine, run iptables -nvL as root to see the port blocking configuration.

If you don't know where the firewall is, you can locate it by running tcptraceroute 192.168.0.12 111 (or 2049, if it's the nfs port that's blocked). But given that the machines are in the same subnet, there's probably a direct connection, so it's the server (or, less likely, the client) that's blocking connections.

Oh, and don't chmod 777. That never solves anything, and usually breaks something. If the error isn't “permission denied”, the solution isn't chmod; and if the error is “permission denied”, the solution may be chmod but not 777.

2

execute this:

#on the server new

yum -y install nfs-utils

mkdir /var/mnt

chmod -R 755 /var/mnt

chown nfsnobody:nfsnobody /var/mnt

#edit vim /etc/exports

/var/mnt IP_OLD_SERVER(rw,sync,no_root_squash,no_all_squash)

#execute

systemctl restart nfs-server

systemctl restart rpcbind

systemctl restart nfs-lock

systemctl restart nfs-idmap

systemctl disable firewalld

#on the old server

yum -y install nfs-utils

mkdir -p /mnt/paste

#execute

systemctl restart nfs-server

systemctl restart rpcbind

systemctl restart nfs-lock

systemctl restart nfs-idmap

mount -t nfs IP_NEW_SERVER:/var/mnt /mnt/paste/

1

**Just give ✔️✔️✔️

Systemctl restart nfs-server

=This will restart the nfs-server not other nfs.

Not the ✖️✖️✖️ Systemctl restart nfs

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 22, 2023 at 16:35
0

Have a look into /etc/hosts on the server. Some systems (ubuntu) insert a silly entry for your chosen hostname, if dhcp was used during installation.

127.0.1.1   klaas.somewhere.de  klaas

Replace 127.0.1.1 with the real IP and restart the nfsserver.

0

This is what worked for me.

#server ip is 192.168.10.20
mkdir /home/servershare
mount -t nfs 192.168.10.20:/nfs/sharefolder /home/servershare -o nolock,rw
2
  • Were you getting "Connection refused" like the OP was? I don't see anything in your solution that would affect that situation.
    – Jeff Schaller
    Commented Aug 19, 2021 at 20:16
  • Just had same problem mounting nfs share on nas server with chinese NVR as host. What worked for me was adding '-o nolock,rw' to the command. Like I said, it worked for me, don't know why, it just did. Don't know why stuff just works for some people and not for others.
    – 5p0ng3b0b
    Commented Aug 20, 2021 at 0:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .