HostOnNet Blog

Amazon Ec2 Cpanel FTP I won’t open a connection to X (only to Y)

When i try to download backup from Cpanel server to Amazon EC2 instance using FTP, i get following error

I won’t open a connection to X (only to Y)

root@ip-172-31-21-166:~# ftp cpanel-hosted-site.com
Connected to cpanel-hosted-site.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 150 allowed.
220-Local time is now 14:43. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (cpanel-hosted-site.com:root): cpaneluser
331 User cpaneluser 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 172.31.21.166 (only to 34.229.5.66)
ftp: bind: Address already in use
ftp> 

The problem is fixed by enabling passive mode in FTP by running “passive” command in FTP prompt.

passive

Example

root@ip-172-31-21-166:~# ftp cpanel-hosted-site.com
Connected to cpanel-hosted-site.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 150 allowed.
220-Local time is now 14:47. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (cpanel-hosted-site.com:root): cpaneluser
331 User cpaneluser OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> passive
Passive mode on.
ftp> dir
227 Entering Passive Mode (192,185,210,215,161,246)
150 Accepted data connection
drwx--x--x   18 cpaneluser   cpaneluser         4096 Jul  9 14:37 .
drwx--x--x   18 cpaneluser   cpaneluser         4096 Jul  9 14:37 ..
-rw-r--r--    1 cpaneluser   cpaneluser           18 Jul 18  2013 .bash_logout
-rw-r--r--    1 cpaneluser   cpaneluser          176 Jul 18  2013 .bash_profile
-rw-r--r--    1 cpaneluser   cpaneluser          124 Jul 18  2013 .bashrc
-rw-------    1 cpaneluser   cpaneluser           25 Oct 31  2013 .contactemail
drwx------    5 cpaneluser   cpaneluser         4096 Jul  9 14:43 .cpanel
drwx------    4 cpaneluser   cpaneluser         4096 May  5 01:13 .cphorde
-rw-r--r--    1 cpaneluser   cpaneluser          500 Feb 27  2012 .emacs
-rw-------    1 cpaneluser   cpaneluser           17 Jul  8 00:49 .ftpquota
-rw-r--r--    1 cpaneluser   cpaneluser          126 Oct 31  2013 .gemrc
-rw-r--r--    1 cpaneluser   cpaneluser          139 Apr  6 14:14 .htaccess
drwxr-x---    2 cpaneluser   99               4096 Oct 31  2013 .htpasswds
-rw-r--r--    1 cpaneluser   cpaneluser          121 Jul  8  2013 .kshrc
-rw-------    1 cpaneluser   cpaneluser          640 Jul  9 14:15 .lastlogin
drwxr-----    3 cpaneluser   cpaneluser         4096 Jan 26  2014 .pki
drwxr-xr-x    3 0          0                4096 Dec  1  2015 .security
drwx------    2 cpaneluser   cpaneluser         4096 Jul  6 01:05 .subaccounts
drwx------    2 cpaneluser   cpaneluser         4096 Oct  4  2014 .trash
lrwxrwxrwx    1 cpaneluser   cpaneluser           34 Oct 31  2013 access-logs -> /usr/local/apache/domlogs/cpaneluser
-rw-------    1 cpaneluser   cpaneluser   1668532513 Jul  9 14:37 backup-7.9.2017_14-19-53_cpaneluser.tar.gz
drwxr-xr-x    2 cpaneluser   cpaneluser        20480 May  5 01:13 cache
-rw-r-----    1 cpaneluser   cpaneluser            1 Jan  8  2017 cpbackup-exclude.conf
drwxr-x---    4 cpaneluser   12               4096 Jul  9 14:15 etc
drwxr-x--x   11 cpaneluser   cpaneluser         4096 Apr  8 16:11 mail
drwxr-xr-x    4 cpaneluser   cpaneluser         4096 Jun 22 01:56 perl5
-rw-r--r--    1 cpaneluser   cpaneluser        38496 Nov 11  2016 php.ini
drwxr-xr-x    2 cpaneluser   cpaneluser         4096 Nov 26  2015 public
drwxr-xr-x    3 cpaneluser   cpaneluser         4096 Nov  1  2013 public_ftp
drwxr-x---   15 cpaneluser   99               4096 Jul  3 23:49 public_html
drwxr-xr-x    5 cpaneluser   cpaneluser         4096 Jan  8  2017 ssl
drwxr-xr-x    8 cpaneluser   cpaneluser         4096 Apr 26 02:02 tmp
lrwxrwxrwx    1 cpaneluser   cpaneluser           11 Oct 31  2013 www -> public_html
226-Options: -a -l 
226 33 matches total
ftp> get backup-7.9.2017_14-19-53_cpaneluser.tar.gz
local: backup-7.9.2017_14-19-53_cpaneluser.tar.gz remote: backup-7.9.2017_14-19-53_cpaneluser.tar.gz
227 Entering Passive Mode (192,185,210,215,124,215)
150-Accepted data connection
150 1629426.3 kbytes to download
226-File successfully transferred
226 154.488 seconds (measured here), 10.30 Mbytes per second
1668532513 bytes received in 154.59 secs (10.2930 MB/s)
ftp> 

Posted in Cloud