Cannot connect via FTP

Hi, I having a problem connect via FTP, Error said

Status: Connecting to… Response: fzSftp started, protocol_version=9 Command: open “root@” 22 Error: Could not connect to server

I have been able to connect before. but now I cant. Please help. Thank you.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @tor9togethers,

You’ll need to make sure you have your IP whitelisted on your droplet and your port opened.

To do so, SSH to your droplet

ssh root@YourDropletIP

Then once you are in, open port to 21(FTP)

iptables -A INPUT -i eth0 -p tcp -m tcp --dport 21 -j ACCEPT

The above will allow the port for everyone. If you want to allow it only for your IP, run the following

iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX --sport 1024:65535 -d XXX.XXX.XXX.XXX --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s XXX.XXX.XXX.XXX --sport 21 -d XXX.XXX.XXX.XXX --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

Please remember to change XXX.XXX.XXX.XXX with your actual IP address.

Additionally, you might want to allow traffic to your droplet for every port from your IP address, you can achieve this by running the following commands

/sbin/iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp -d  XXX.XXX.XXX.XXX -j ACCEPT

Again, please remember to change XXX.XXX.XXX.XXX to the actual IP address.

Regards, KDSys