I'm trying to connect to an FTP Server via Commandline in Ubuntu Terminal. But, I'm getting following error.

FTP connect Mode : Active Mode

$ ftp xxx.xxx.xxx.xxx

Connected to xxx.xxx.xxx.xxx

421 Service not available, remote server has closed connection

Can anyone please help me figure out a way to connect to the FTP server.


PS: the site is live & working fine on a subfolder on the same IP.

  • This is a very poor question. It's an FTP server, not "an FTP". You are using some form of FTP client program, not Terminal (which is not an FTP client). The activex tag seems nonsensical. And you are trying to fix the FTP server so that it does not reject your client with a 421 not the client, right? So what is the FTP client software? What is the FTP server software? And how has the latter been configured? All of that should be in the question from the start. – JdeBP Dec 25 '17 at 12:39

This looks like the FTP server is accepting the incoming connection, then immediately rejecting it even before FTP active/passive mode is even chosen.

This might happen because the server is using tcpwrappers or libwrap, and the server's /etc/hosts.allow and/or /etc/hosts.deny files are configured to reject any FTP connections from your IP address.

You cannot fix this with your Ubuntu system, except by perhaps moving your client system to an IP address that is on the server's allowed list. But that would require knowing which IP addresses are allowed and which are not.

You probably should contact the administrators of the FTP server and troubleshoot this with them. Only they could allow your access.

You'll need to make a FTP connection attempt from your system, note the exact time and the IP address, and then ask the server administrator: "Does this FTP connection attempt (at this time, from this IP) show in the server logs at all? If it does, does it say it is rejecting the connection? If rejecting, does it say why?"

If there is no record at all from your login attempt, then either the server is configured to not log failed logins (unusual but possible) or something in the network between your system and the server is blocking the connection. Then the next questions would be to the network administrator: "Between this IP address and this server, is there a firewall or other device that could be capable of identifying and rejecting a FTP connection? If there is such a device, is it configured to reject a FTP connection from your system to the server? Who is the administrator of that device?"

If there is a log entry of your connection attempt in the server logs, then it proves the network is allowing your connection to pass, and the server itself might be rejecting your connection - and if that's true, the log entry would probably say so. Then it's a matter of finding the bit of server configuration that is causing the rejection, and adjusting it as appropriate.

  • After lot of back n forth emails, I got the Network Admin to test the credential on his Machine. And, it works for him. He even send the screenshots. – Shailesh Feb 6 '18 at 8:03
  • That proves the server works and is configured to accept connections from his IP address. But the problem seems to be an IP address based rejection. See my edited answer. – telcoM Feb 6 '18 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.