What are the steps to resolve the error '421 service not available' in case of ftp?

In this article, we will cover several steps and solutions if you are finding ‘421 service not available` when attempting to connect to your server via FTP. This article may also be helpful if you are finding other similar problems or issues when attempting to establish a successful connection while using your FTP client from your local workstation.

This article applies to systems running CentOS or Linux distributions.

Step 1. Rule out DNS issue.

If you are attempting to connect with your server hostname or domain, it is worth ruling out a possible DNS or resolution issue. To accomplish this, the easiest way is to simply use your servers IP address instead of the hostname or domain.

See examples below how this may look in your FTP Client. We recommend if unfamiliar with FTP to consider installing/using FileZilla, it's free! https://filezilla-project.org/download.php

Filezilla connection configuration settings hostname  

Filezilla connection configuration settings IP

If you are able to confirm successful login when using IP, we recommend using below sites to test your domain/hostname for possible DNS problem.

whatsmydns.net - Using this site, search your domain, select A in the drop down (default), you can then check the IP address as the world is finding.  If you see this is not your server IP, you should consider testing the domain in the next site.

Intodns.com - Testing your domain here will give you the nameservers you have configured your domain with.  If you are finding these nameserver records not configured to your server IP, it means you could be using external DNS nameservers to control your domain or perhaps your domain has expired.  Your domain registrar or domain DNS provider is likely the best point of contact for either of the above scenarios. If you are using us as your DNS provider, nameservers should report: ns1.hivelocity.net && ns2.hivelocity.net here.  You can manage your domain records from your my.hivelocity.net -> Network -> Select domain

If you are still seeing an error and all DNS reporting seems to be in good shape, please move on to step 2.

Step 2. Try SFTP

If you are still finding an issue when attempting with IP directly, we would recommend trying SFTP protocol and changing the port you’re connecting with to match your servers SSH port. By default this can be 22 but on many systems, this can be different in order to enhance security and prevent common brute force attempts. If you want to connect to your server with root user and not a secondary or FTP user, some systems require the use of SFTP - this is a more secure protocol and we recommend using SFTP whenever possible for best practice.

 FTP error 421 when attempting to connect with an IP address directly using SFTP protocol using custom SSH port

If you wish to learn more about further enhancing system security, check out some of our other enhancements we offer: https://www.hivelocity.net/enhancements/ddos-protection/

If you are still seeing ‘FTP error 421’ after attempting step 1 and 2, please refer the following steps to resolve it:

Step 3. Check the /var/log/messages log file on the server.

getaddrinfo 'Hostname_Is_Here' error: Name or service not known
warning: unable to determine IP address of 'host.domain.tld domain'

This is because the FTP server cannot determine the IP address of the server by hostname. 

Step 4. Try to PING hostname.

#ping hostname

If ping does not respond, you will have to define the correct hostname in the configuration files as follows and restart network service.

/etc/init.d/network restart 

Step 5. If still the following error occurs...

Authentication failed for user [anonymous]

 ...proceed to step 6.

Step 6. Server blocking or service configuration.

If you find this issue with SFTP as well, this could be the result of firewall rules of the system or perhaps a system misconfiguration causing you to not be able to connect properly.

a) cPanel systems (see b for other distributions)

If you are running a cPanel system, the two likely places you would need to allow your IP address in order to allow yourself access to the system, you can allow your IP from your WHM panel.

First, gather your workstation IP from URL here, this is what you will use to replace YourIPAddress in below items:


 How to find your workstations global IP from our website.  This is helpful when troubleshooting issues such as FTP error 421

You can access your WHM panel one of two ways:

WHM | https://YourServerIPAddressHere:2087 (ignore the security warning and proceed) or WHM | https://YourServerHostname:2087

Once in your WHM panel, you can allow in both locations:

WHM -> ConfigServer Security & Firewall -> Quick allow

WHM -> CPhulkd -> Whitelist

How to whitelist your workstation IP address from your servers WHM -> Configserver Security & Firewall (CSF).  This is helpful when troubleshooting issues such as FTP error 421

How to whitelist your workstation IP address from your servers WHM -> Cphulk Brute Force Protection (Cphulk).  This is helpful when troubleshooting issues such as FTP error 421

If you prefer to allow from SSH or Terminal instead of within WHM, you can perform below to allow:

$ csf -a YourIPAddress
$ /scripts/cphulkdwhitelist YourIPAddress

421 service not available FTP Terminal IP allow

b) Other Linux distributions

Other Linux systems or installations may use other firewalls.  For example, Ubuntu may be running ufw while other non-panel, Redhat, or Centos may be using iptables or firewall.  It would be recommended to attempt to temporarily stop these or attempt to whitelist/allow

Step 7. Issue a support ticket.

If you have exhausted your efforts or would like some assistance checking the issue further, please reach out to us from your my.hivelocity.net account -> Support and provide your server credentials within the Encrypted field for best possible security and support.

If you are unable to reach your my.hivelocity.net account or if you are on the go, please reach out from your valid my.hivelocity.net account email to us here: support@hivelocity.net

We are also available to you through our phone and live chat system 24/7/365.

If you thought that was helpful, check out this article on How to mount your cloud storage drive on your CentOS, RHEL or Fedora systems from our Impressive Support staff.