What's happening on your site right now?

Find out with GoSquared. Real-time web analytics.


Try GoSquared Free.

Dev with Geoff - Development time with our CTO Geoff Wagstaff

For a while I was forced to connect to FTP (an installation of VSFTP) on our EC2 server using Active mode, because passive mode refused to work. While this is OK for FTP clients that can be configured to use active mode, other utilities such as screen capture (e.g. Jing) and the wordpress auto-upgrade could not work with active mode, causing all sorts of erroneous malarky.

If you’re getting errors such as “227 entering passive mode… Connection [Failed/Timed out]” this may work for you

I decided enough was enough and set about problem-solving: the developer’s favourite. It turns out, as usual, the problem relates to the ports the EC2 firewall opens for its instances, namely, none at all. Since passive mode connects to any random port > 1023, this is a problem. So, what you will need to do is define a fixed port range for VSFTP to use for PASV connections and then allow these in your “Security Groups” firewall rules.

Note: This method will probably work on any server, just add the config settings and then open the correct ports in your software firewall or router

1. Specify a port range in which VSFTP will run PASV connections
Add the following lines to your vsftpd.conf file:

pasv_enable=YES
pasv_max_port=12100
pasv_min_port=12000
port_enable=YES

You also need to add an extra line to specify which IP address VSFTP will advertise in response to a passive connection, so underneath the lines you’ve already pasted in vsftpd.conf, put:
pasv_address={your public IP address}

OR if you don’t have a fixed elastic IP address:

pasv_addr_resolve={your public domain or DNS}

2. Authorise required ports in a security group that applies to your instance

This can be done via the AWS management console (Amazon’s EC2 web control panel), or in your own console:

ec2-authorize default -p 20-21
ec2-authorize default -p 12000-12100

Now restart vsftpd by typing /etc/init.d/vsftpd restart in your server’s terminal.

If all goes well and it’s your lucky day, passive connections should now work properly.

Who is on my website right now? Find out with GoSquared - real-time web analytics and traffic monitoring.

5 Responses so far Follow Comments on this Post with RSS

  1. 1

    Paul Whipp said,

    November 16, 2009 at 08:37 ()

    Tried exactly this myself and found this post after searching for reasons why it does not work.

    I get:
    ftp> passive
    Passive mode on.
    ftp> ls
    500 OOPS: child died
    Passive mode refused.

  2. 2

    James Tripp said,

    May 22, 2010 at 04:39 ()

    That worked for me, to get my address working, I did this before restarting vsftpd .
    It looks like when you do it this way, when you restart vsftpd, it picks the IP address at boot time and then uses that numeric address.

    pasv_address=www.mysite.com
    pasv_addr_resolve=YES


    You also might want to ftp to your localhost, and see if that works, that will rule out the firewall issue, but not rule out the address issue, because locally your address will be different than externally (why EC2 gives you 2 addresses)

  3. 3

    Philippe said,

    July 12, 2010 at 23:58 ()

    Thanks this did save me some time.

  4. 4

    Lucas said,

    September 11, 2010 at 18:36 ()

    Thanks, this worked for me on Debian EBS AMI

  5. 5

    Amit J said,

    December 31, 2010 at 09:23 ()

    Thanks, this worked for me.

Have Your SaySigned in as | Sign Out

GoSquared Features - respond now, not tomorrow. GoSquared on Facebook - Keep up to date with us on Facebook GoSquared on Twitter - follow us why don't you! About GoSquared