External FTP with My Cloud not working

Ok so curious problem.

FTP enabled on the MyCloud, ports forwarded, user accounts set up perfectly. Using a port checker, port 21 is unreachable.

So I check the port forwarding and restart my router and suddenly it works! However, I try to connect again after disconnecting and now it doesn’t.

Checking a port checker at each stage, port 21 is open, then as soon as I disconnect from my first connection, it closes. 

My FTP works fine internally and I have tested switching off the FTP and attemtping to re-connect. It works as expected, FTP is off when the switch is off and on when it is on, no surpise there. This issue doesn’t happen after a Cloud reboot or reset, only from my router end.

I timed it to see how long it stayed on for (the port) and it seems that it will stay on indefinitely as long as I make no connection to the FTP. 

So what is going on? A port that likes to turn itself off as soon as a connection is made to it? Or the My Cloud only opening FTP externally and failing to block the first connection  to it, then deciding to do so.

It’s such an odd issue and I have found it nowhere else through my searches. Any assistance welcome, thank you. 

EDIT: Forgot to mention I have a QNAP NAS server on the same network and that works perfectly when FTP is enabled, Stays up and can be connected to from anywhere externally and internally, leading me to believe it is a problem with the My Cloud and not the router. I have the FTP on the QNAP turned off though, so there’s no port conflict there even though it wouldn’t create one anyway. 

few extra notes: 

My Cloud is in DCHP mode but with a DHCP reservation on the router to save having to enter all the IP information in the static mode (however, I can do this if necessary, was just a shortcut I took)

Cloud Access IS enabled and with port forwarding active on ports set to Auto (I’ve had issues setting up custom ports for it and it has NEVER worked no matter how much I port forward… issue related?)

Which firmware version are you on? I didn’t notice such issue on neither v3 nor v4.

Try test your port-forwarding via another port e.g. external 2121 to internal nas 21. Ftp to your external_ip:2121 then disconnect see if the same thing occurs.

How about other than ftp port? Sftp and httpd ok?

If after the 1st external connect you’re unable to reconnect to that same port externally, but internally you still can reconnect, then this should be related to the router.

If you have the time, try the test below for incoming raw sockets. First stop the vsftp daemon to free port 21, “service vsftpd stop”. Setup your port-forwarding for port 21 as you normally would.

  1. Create a simple perl script below named “test.pl” and place in the nas home path ~/:

    #!/usr/bin/perl

    use IO::Socket;
    my $port = 21;
    my $l = new IO::Socket::INET (
    LocalHost => ‘wdmycloud’,
    LocalPort => $port,
    Proto => ‘tcp’,
    Listen => 1,
    Reuse => 1,
    );
    die “Socket error: $!\n” unless $l;
    print “Listening on port $port…\n”;
    while(my $s = $l->accept()) {
    print “Incoming " . $s->peerhost .”:$port…\n";
    while(<$s>) {
    print $s->peerhost . “:$port=>” . $_;
    }
    print “\nBye " . $s->peerhost .”:$port…\n";
    close($s);
    }

  2. Run the script within your nas (use ctrl+c to stop the script anytime):

    perl test.pl

 3) Do a few test probes from an external connection to the nas see if it continuously accepts connection. There’s few ways to do this, do a normal “ftp external_ip”, or “telnet/nc external_ip 21”. For telnet or netcat, just type anything and it will appear on the perl script above to prove connectivity. Once you close/disconnect any of these client, you’ll see a reply on the script. Then try again see if you can still reconnect. You can also test other ports, change “my $port = ?”.

1 Like

Hello Nazar and thank you for your reply.

To answer your questionions and advice in order: (for simplicity)

I am on firmware v4 (607, latest) 

I have tried through port 2121 and still no luck there unfortunately, didn’t even connect for me to disconnect. 

Sftp and httpd work fine (22 and 80) I can SSH through Filezilla to the Cloud (though again, only internally)

Just as a point, I have had the firewall turned off and the server under DMZ throughout this entire process,
so I am puzzled as to how there is this much of an issue with external connections.

I’ve just tested my other NAS server and as it turns out, I can connect internally through FTP perfectly, but externally I get a refused connection even though the port is open and forwarded. This led me to look in to the WD Cloud issue a bit more and as it turns out there I get a refused connection too.

So I think it is in fact connecting but just refusing connection.

As for the perl script, I simply get the follow error:

HiggsCloud:~# service vsftpd stop
Stopping FTP server: vsftpd.
HiggsCloud:~# perl test.pl
Socket error: Cannot assign requested address

 the service is stopped and my other NAS server was running on port 27 at the time for testing (which by the way had the same results as port 21, it made no difference)

This is where my file is located on the NAS:

sftp://root@192.168.0.5/root/test.pl

Ok so I have absolurely no idea how but it has started working out of nowhere somehow, I haven’t changed any settings anywhere, though I did modify my port forwarding to exactly what it already was… really quite confused. 

Watch this space, it may break again

I noticed you’ve renamed your mycloud, so for the perl script either replace the hostname with yours or just comment it out “#LocalHost => ‘wdmycloud’,”.

You also mentioned you’ve tested turning on the DMZ mode for mycloud. Just to take note that on some router, the port-forwarding precedes DMZ connection and some succeeds. E.g. to test DMZ mode for certain ports, you’ll need to remove that port from port-forwarding.

From your latest reply, I strongly feels that it’s the router at fault. See the router logs if there’s any hint or if firmware downgrade/update or factory reset might help.

The router will refuse external connections if there’s issues somewhere with the port-forwarding i.e. wrong local destination ip or the destination isn’t listening on the port like below:

nazar@TeaNazaR4TB:~$ sudo netstat -natp | grep 21
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 7770/vsftpd

Other than DMZ or manual port-forwarding, you can also try upnp if your router supports and turned on. To do this, clear the DMZ/port-forwarding on your router. Then you will need something like miranda-upnp a python based script (sometimes failed to find my router). Or miniupnpc (works with my router) i.e. “upnpc [options] -a ip port external_port protocol [duration]”. For mycloud firmware v4, you’ll need to build these below patched with 64K page memory size.

nazar@TeaNazaR4TB:~$ dpkg -l | grep miniupnpc
ii libminiupnpc-dev 1.6-4 armhf UPnP IGD client lightweight library development files
ii libminiupnpc8:armhf 1.6-4 armhf UPnP IGD client lightweight library
ii miniupnpc 1.6-4 armhf UPnP IGD client lightweight library client
ii python-miniupnpc 1.6-4 armhf UPnP IGD client lightweight library Python bindings
1 Like

Thank you for your advice, I will certainly keep this in mind for the future.

I am not sure but I think it is because I was port forwarding to my other NAS at one point, left that port forwarded and then added a rule for my WD Cloud and there was some sort of mixup there, because upon deleting all my port rules and adding the one just for the WD Cloud it works, so I think this part:

“The router will refuse external connections if there’s issues somewhere with the port-forwarding i.e. wrong local destination ip or the destination isn’t listening on the port

hits it right on the head. 

Thank you for your help!