The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FTP Out

Discussion in 'General Discussion' started by retsman, Dec 18, 2012.

  1. retsman

    retsman Member

    Joined:
    Oct 19, 2012
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I can't seem to connect out using FTP and PHP on my server.
    PHP:
    $ftp_server "ftp://mydomain.com";
    $ftp_user "AlphaTest";
    $ftp_pass "P$d8^fs2";

    // set up a connection or die
    $conn_id ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 
    // try to login
    if (@ftp_login($conn_id$ftp_user$ftp_pass)) {
        echo 
    "Connected as $ftp_user@$ftp_server\n";
    } else {
        echo 
    "Couldn't connect as $ftp_user\n";
    }
    // close the connection
    ftp_close($conn_id);  
    Just comes back with message "Couldn't connect to ???"
    Any idea where in WHM this could be examined to find the cause.

    I now the server is online as I can ping it from my desktop.
     
  2. PlotHost

    PlotHost Well-Known Member

    Joined:
    Apr 29, 2011
    Messages:
    253
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    US
    cPanel Access Level:
    Root Administrator
    Twitter:
  3. PenguinInternet

    PenguinInternet Well-Known Member
    PartnerNOC

    Joined:
    Jun 20, 2007
    Messages:
    149
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Cardiff, UK
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Check that your firewall is allowing outbound FTP connections too as a very basic check
     
  4. retsman

    retsman Member

    Joined:
    Oct 19, 2012
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Yeah I did just that and I also did another test where I can certainly connect to my second server and it works.
    Its just ONE server that I can't seem to connect.

    When I call the company they said they don't even see an attempt to connect.

    What I was able to verify is this.


    1. using this very basic FTP test I can connect to 4 different servers and accounts, no problem.
    2. I try to connect to the server I really need to connect to and it wont even answer.
      • This normally means the target server I'm trying to connect to either isn't answering or
      • I have the wrong credentials.
    However neither is the case. I take my script, move it to server 3 and can connect to the target, no problems at all. I move the script back to my first server, connection no longer works even though simply modifying that script to connect to any other FTP works just fine. I thought my IP was blocked??? Turns out they can't even see my attempt.​

    I'm at a loss, I turn off the firewall, no luck. Please tell me this really seems like an issue on their server and not mine.
     
  5. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    Did you try to use the destination server's IP address?
     
  6. retsman

    retsman Member

    Joined:
    Oct 19, 2012
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Yeah but I think I may have found the problem just not the solution.
    Apparently they only allow authorized IP's to connect. So I added mine to their list of approved IP's, I then go to WHM and "Change Sites IP" to the dedicated IP, try to connect and it shows on there end as the IP for the server, not the dedicated so I think its a mapping issue.
     
  7. PlotHost

    PlotHost Well-Known Member

    Joined:
    Apr 29, 2011
    Messages:
    253
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    US
    cPanel Access Level:
    Root Administrator
    Twitter:
    Interesting ... :) Try to connect with IP instead of the domain name -- ftp://IP
     
  8. retsman

    retsman Member

    Joined:
    Oct 19, 2012
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Yep tried that, here is whats strange. I changed the sites IP, my site that is, to a dedicated IP, try to connect to the FTP server and they see my servers IP not the domains IP. Very Strange.
     
  9. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,279
    Likes Received:
    36
    Trophy Points:
    48
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    That's to be expected. No matter whether you are using the server IP or a dedicated site IP, your scripts aren't just going to bind to that dedicated IP to send anything out. There are likely ways to try and accomplish that, but it won't happen by default.

    M
     
Loading...

Share This Page