Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I try to use the php ftp_connect fucntion on my dedicated server and I'm unable to establish a connection:

$conn_id = ftp_connect($ftp_server, 21) or die("Unable to connect to $ftp_server") ;

I'm sure the function is available as I test with :


and it returns true

When I ftp the server through the shell I can reach it so I guess it's not a firewall issue. Am I missing something else ?

Thanks for your precious advices

share|improve this question
Check for logged PHP errors/warnings. – Michael Hampton Sep 5 '12 at 8:48
I've checked and nothing. The function return false. I don't understand as the same code on my local machine works like a charm. – Dude Lebowski Sep 5 '12 at 8:59
up vote 0 down vote accepted

PHP will log a warning if ftp_connect fails. However, you may have logging disabled or going to an unexpected place. Check your php.ini and related configuration files to ensure that logging is enabled and to specify where the logs are written.

To diagnose this problem without access to logs, try running PHP from the command line. For instance:

$ php
<?php $x = ftp_connect("");


PHP Warning:  ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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