My Server OS: Amazon Linux

I am trying to set up ftp. I have:

  • Installed vsftpd

  • open port 20-21

  • open port 1024 - 1048

Basically, I followed every of these steps

  • Start vsftpd service (the status indicate [ok])

I use filezilla for my ftp client.

Here is my setting/configuration:

Host: ec2-XX-XX-XXX-XX.compute-1.amazonaws.com

Port: -(blank, but I have tried 20 and 21 though)

Server Type: FTP - File Transder Protocol

Logon Type: Normal

Username: (tried root and ec2-user)

Transfer mode: Tried passive and active

I always has this error:

Status: Waiting to retry...
Status: Resolving address of ec2-XX-XX-XXX-XX.compute-1.amazonaws.com
Status: Connecting to XX.XX.XXX.XX:21...
Error:  Connection timed out
Error:  Could not connect to server

Have I missed any configuration/settings?


After execute the /sbin/iptables -L -n

Here is the result:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
  • 3
    When you say "Open port 20-21 & 1024-1048" do you mean in the relevant security group or in IP tables? – Decado Aug 1 '11 at 10:25
  • Sounds like security groups to me as well... – iainlbc Nov 26 '11 at 17:50

You have to enable passive mode in vsftpd, and make it listen to the elastic IP of your instance:

  • pasv_enable=YES
  • pasv_min_port=1024
  • pasv_max_port=1048
  • port_enable=YES
  • pasv_address=Elastic IP

Also, open up ports 1024-1048 in the server's security group, and on your linux server. Dont forget port 21 as well ;)


If you just want to transfer files between your EC2 instance and your local machine, I don't see a reason you need to install an FTP server. You can either use psftp or filezillia with your private key to connect to your EC2 instance securely over port 22. This post has step by step instructions. http://lzw-programmingjourney.blogspot.com/2011/12/set-up-ftp-server-on-amazon-aws-ec2.html


From the log, it is clear that the port 21 is being blocked at some way.

At server side, you need to check if VSFTPD is listening on ALL IP addresses,, and check it with command

netstat -ntlp

After that, the port 21 should be open in the Amazon cloud security group, from desired IP address.

Before initiating any connection to the server, try to run NMAP port scan to see if the port 21 is actually open from client side. for it run:

nmap -vv -P0 (server IP address or DNS)


You don't say which Linux distro you are using so it's hard to be sure but I suspect that you need to configure the Linux firewall (iptables) to allow FTP.

Try the following

sudo iptables -I INPUT  -p tcp -m tcp --sport 20 --dport 1024:1048 -j ACCEPT
sudo iptables -I INPUT -p tcp -m tcp --dport 21 -j ACCEPT

EDIT It doesn't look like your EC2 instance iptables is the problem so it must be something else. In you AWS console check that the instance is in the default security group and that the default security group contains settings similar to this.

Connection Method   Protocol   From Port   To Port    Source (IP or Group) 
-          tcp      tcp        20          20
-          tcp      tcp        21          21
-          tcp      tcp        1024        1048

If it does then you problem lies elsewhere as something else is blocking your connection.

  • When I did "cat etc/issue", it says: Amazon Linux AMI release 2010.11.1 (beta). How do I configure Linux firewall(iptables)? can show some examples? – heathub Mar 2 '11 at 7:46
  • after i add the command that you provide, i restart apache, and vsftpd, then I try to connect, it still has the same error: Error: Connection timed out Error: Could not connect to server – heathub Mar 2 '11 at 7:52
  • Can you post the output of /sbin/iptables -L -n as an edit to your question. – user9517 Mar 2 '11 at 9:29
  • I have edited my question. Please let me know if u need any information, as I still cant get it work. It works fine with SFTP though, only ftp client(like filezilla) cant connect – heathub Mar 2 '11 at 10:02
  • @heathub: see my edit – user9517 Mar 2 '11 at 10:33

I use Filezilla to login, and follow the steps below.

To connect to a running Amazon EC2 instance with Filezilla:

  1. Edit -> Settings -> Connection -> SFTP Click "Add keyfile"

  2. Browse to the location of your .pem file and select it.

  3. A message box will appear asking your permission to convert the file into ppk format. Click Yes, then give the file a name and store it somewhere.

  4. If the new file is shown in the list of Keyfiles, then continue to the next step. If not, then click "Add keyfile..." and select the converted file.

  5. File -> Site Manager

  6. Add a new site wih the following paramerters:

    Host: Your public dns name of ec2 instance

    Protocol: SFTP

    Logon Type: Normal

    User: ec2-user

Press Connect Button

Video Tutorial: Click Here

  • SFTP is not FTP. They're totally different protocols. – ceejayoz Nov 1 '13 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.