Question

PHP ftp_connect() can't establish a connection

Hi, I’m trying to establish a connection to digitalocean droplet from localhost to do ftp functions using PHP script but it is failing. Does digitalocean servers allow connecting from a remote script or i’m missing something? Your assistance will be much appreciated. See the code I’m using below:

// my ftp server $ftp_server = “159.203.186.99”;

// connect to FTP server $ftp_conn = ftp_connect($ftp_server) or die(“Could not connect”);


Submit an answer
Answer a question...

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.

KFSys
Site Moderator
Site Moderator badge
September 25, 2022

Hi @samunyi90,

Yes, DigitalOcean servers do allow connecting from a remote script/host. I would assume the issue lies somewhere else. The best thing you can do is to check your DigitalOcean Droplet’s logs and see the reason behind the failure.

alexdo
Site Moderator
Site Moderator badge
September 24, 2022

Hello @samunyi90

Are you able to connect via FTP using an FTP client like FileZilla? Also if you’re running custom Firewalls rules, make sure to whitelist the IP from which the connection is established.

Regards

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.