ftp_put() [function.ftp-put]: Failed to establish connection - php

I'm trying to ftp upload file using php. Managed to connect via ftp_connect, and ftp_login. That means the connection / credential's ok. However when I try to run ftp_put, it comes out with that error.
ftp_put() [function.ftp-put]: Failed to establish connection
Anyone know what could be causing that problem?

Related

PHP file() - Failed to Open Stream: Connection timed out

I'm having a problem troubleshooting this issue about "failed to open stream: connection timed out". There is this application deployed in a server (ip.server.of.main.app). In some part of its code, it is posting data using this code:
$f = file('ip.server.of.another.app/tracker.php?var1=value1&var2=value2')
This ip.server.of.another.ap/tracker.php?var1=value1&var2=value2 is posting the data of the variables passed on the script.
But this line always timed out. In my local pc, when I run a test code containing that line, it didn't timed out and successfully posted the data on the database.
Is there any possible cause why it only timed out when run on the server of the main app?

mysqli_connect(): (HY000/2002): A connection attempt failed to the remote server

I am trying to connect to a remote mysql server, but I get the
Warning: mysqli_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
This connection worked until a few days back, but I suspect an antivirus update changed the permissions for the port. I am unable to figure it out and it's already frustrating.
I am using XAMPP, which I already reinstalled. I have also tried in WAMP, so it is not local webserver related.
Telnet fails when opening connection to host, my IP is allowed on the remote server.
I have also disabled the antivirus and firewall temporarily, but still fail to connect. What else should I try?
First check no other application is using the port. Because of the problem MySQL can't start at the port . check it and is not work means reinstall the xampp with another place like D: , E: , something else.

Cannot connect to external FTPS server with php

I need to extract data from a .gz file which is located on an ftp server. The FTP server works with IP white listing, so I submitted my local IP and my website IP (i used gethostbynameto get the IP) which were both approved.
Locally, I can run this code to reach the file:
$url="ftp://username:password#host/targetfile.gz";
$xml = simplexml_load_file("compress.zlib://$url") or die ("Cannot load file");
This runs perfectly fine and it allows me to extract data from the XML file.
When I run the script on my server however, i'm not getting a connection. I contacted the admin running the ftp server and they told me they only allow FTPS connections.
So, I proceeded with the following code to try and establish a connection:
$conn_id = ftp_ssl_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
if (!$login_result) {
die("Cannot login.");
}
echo ftp_pwd($conn_id); // /
// close the ssl connection
ftp_close($conn_id);
This also doesn't connect. I'm new to FTP connections with PHP and FTP in general and i've got no clue on how to proceed from this point.
OpenSSL is enabled.
Can anyone point me in the right direction?
Edit: These are the error messages:
When I use the top block of code, this occurs:
Warning: simplexml_load_file(): I/O warning : failed to load external
entity
"compress.zlib://username:password#ftp.thehost.com/targetfile.gz"; in
/path/to/my/website/folder/htdocs/mydomain.com/feeds/script.php on
line 13
When I use the bottom block of code, I get this error:
Warning: ftp_login() expects parameter 1 to be resource, boolean given
in /path/to/my/website/folder/htdocs/mydomain.com/feeds/script.php on
line 16 Cannot login.
I do not have access to the log file afaik
I do not think there's much we can help you here.
You do not have a network connectivity between the web server and FTP server.
Note that it does not have to be because the web server has not been white-listed on the FTP server. It's also possible that the web server does not allow outgoing connections.

PHP ftp_put via SSL

One of our suppliers has requested we change from an ftp to ftps for sending them files.
I have a PHP script that uses ftp_connect to transfer the files.
I've modified the script to now use ftp_ssl_connect and while it can open the connection and login, it fails to transfer the files.
This is the error I get from the ftp_put operation:
"Warning: ftp_put(): Unable to build data connection: Operation not permitted in....."
Could this be a firewall issue? The server is an EC2 instance.
Paddy
I ran into the exact same problem today. Using
ftp_pasv($conn_id, true);
to enforce passive transfers before the actual call to ftp_put() solved the problem for me.

Local php-mysql install not connecting to remote db?

I'm trying to connect to a remote database from my local machine, and php is throwing a nice vague error, so I was hoping someone with a bit more experience in this area could point me in the right direction. The error I'm getting:
Warning: mysql_connect() [function.mysql-connect]: Connection refused in /my/obfuscated/directory/config.php on line 10
Could not connect: Connection refused
Your error is "Connection refused". So, remote sever refuse your request.
Try to configure remote server to allow your connection

Categories