PHP-FTP connection

Hey, dear everyone!
I’ve just noticed today that it’s not possible to connect to my SFTP via PHP while using cloudflare.
How can this thing be fixed? -> this is my site’s link, is referring to the original IP for my VPS.
Thanks in advance

Also, i’m 100% sure that everything’s correct, I connect to my SFTP with the same details. Also, it works if I connect to my VPS via WinSCP, so I really don’t know where’s the problem.

That SFTP server is reachable for me.

1 Like

exactly, but not via PHP. and I need to connect to my SFTP server via PHP. I can’t solve a thing without it

Then the problem pretty sure is somewhere at the server the PHP script runs on.
May you have blocked outgoing ports or something like this.
Also we can not see the PHP-Code which is getting executed. Also possible there are some errors/missconfigurations

1 Like
// connect and login to FTP server
$ftp_server = "";
$ftp_username = "root";
$ftp_userpass = "censored";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server / username / password");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

// then do something...

// close connection

I don’t think there’s any error in this code. It worked before I used Cloudflare.

You pretty sure are using normal FTP which connects to port 21 (FTP-Port)

SFTP Standardport is 22. Please specify the Port and you should be fine

I would recommend this:


1 Like

Yes exactly, thank you so so much.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.