The EAI_NONAME error in FTP occurs when the FTP client cannot resolve the hostname to an IP address. This is a DNS issue, meaning your system cannot find the FTP server.
The first step is to verify if your computer can resolve the FTP hostname to an IP address at all.
Run this command in your terminal or command prompt:
nslookup ftp.yourdomain.com
or
dig ftp.yourdomain.com
Expected Result: You should see an IP address in the output (e.g., 192.168.1.10). If you do, DNS is working.
Error Result: If it says "server can't find ftp.yourdomain.com: NXDOMAIN", DNS is broken and you need to apply the fixes below.
This is the most direct workaround to bypass DNS entirely.
Instead of using the hostname:
ftp ftp.yourdomain.com
Try connecting with your server's IP address:
ftp 192.168.1.10 # Replace with your server's actual IP
If this works, you have confirmed the problem is with DNS resolution. You can use the IP address from now on, or follow the next step for a permanent fix that allows you to keep using the hostname.
If you need to use the hostname (e.g., for scripts or convenience), you can manually map it to the correct IP on your local machine by editing the hosts file.
/etc/hosts file with a text editor (requires administrator/root privileges):
sudo nano /etc/hosts
192.168.1.10 ftp.yourdomain.com
Now, when you run the command, your system will use this local mapping:
ftp ftp.yourdomain.com
And it should resolve correctly.
Sometimes, the connection issue might be related to network blocking. Standard FTP uses port 21.
Check if your firewall is currently blocking FTP:
sudo ufw status
To explicitly allow FTP traffic through the firewall, run:
sudo ufw allow 21/tcp
Restart the firewall service to apply the rule:
sudo systemctl restart ufw
Now retry your FTP connection.
To ensure your system picks up any network or DNS changes, it's good to restart services and clear old cached data.
Restart the networking service (this command may vary by Linux distribution):
systemctl restart networking
Flush the system's DNS resolver cache to force it to fetch fresh records:
systemd-resolve --flush-caches
After these commands, try connecting to your FTP server again.
As a final diagnostic step, try connecting with a different FTP client, such as FileZilla, WinSCP, or your web hosting control panel's file manager.
If the other client connects successfully, the issue might be specific to your command-line FTP client's configuration or environment.
If it fails with the same error, it confirms a system-wide DNS or network problem, reinforcing the need for the fixes above.
| Issue | Fix |
|---|---|
| FTP hostname not resolving (EAI_NONAME) | Use IP instead of hostname |
| DNS failure | Add entry to /etc/hosts |
| Firewall blocking FTP | Run sudo ufw allow 21/tcp |
| System using old DNS records | Flush DNS with systemd-resolve --flush-caches |
By following these troubleshooting steps, FTP should connect without EAI_NONAME errors!