When you deal with FTP connections sometimes you may see the below message, when you attempt to do the directory listings or get the files from the Server.
500 I won’t open a connection to <<internal-ip-address>> (only to <<external-ip-address>>)
ftp: bind: Address already in use
Let’s try to reproduce the problem. I have connected to a Server with the user credentials.
paul:~$ ftp ftp.sample-domain-name.com 21
Connected to sample-domain-name.com.
220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
220-You are user number 4 of 150 allowed.
220-Local time is now 10:45. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (ftp.sample-domain-name.com:user): myuser
331 User myuser OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
500 I won’t open a connection to <<internal-ip-address>> (only to <<public-ip-address>>)
ftp: bind: Address already in use
Observe that, from above commands, when attempted to show the directory listings using dir
command; it was throwing the above message.
Usually we get these messages when there is a non-permanent connection between the Server and the Client. And also we need to understand in which mode FTP connection is working. There are Active and Passive modes where we can establish the FTP Client connection with the FTP Server.
When the FTP Client attempts to connect to the FTP Server, both has to share the IP Addresses of their Systems. If these Systems are behind the firewall, they have Internal IP Address (or Private IP Address) and External IP Addresses (or Public IP Address).
When FTP Client sends it’s Private IP Address to the FTP Server; FTP Server can’t recognize this Internal IP Address and it can only recognize the Public IP of the FTP Client; throws a message shows “500 I won’t open a connection to …”.
To resolve this, FTP Client has to connect to the FTP Server in Passive mode. This can be possible, just by typing the passive
command at the ftp command prompt.
In Passive mode, FTP Client can send it’s Public IP to FTP Server and then FTP Server can recognize this to establish the connection with FTP Client.
ftp> passive
Passive mode on.
After entering into passive mode, type dir
command at ftp prompt to show the directory listing.
ftp> dir
227 Entering Passive Mode (xx,xx,xx,xx,xx,xx)
150 Accepted data connection
We discuss more topics through upcoming Articles.
Paul
Thank you! This worked!