i include the use \Magento\Framework\Filesystem\Io\Ftp; at the top nd connct the ftp as

 $connection = $this->ftp->open(
                        'host' => '',
                        'user' => 'admin',
                        'password' => 'test@123',
                        'passive' => true,


this code is work fine in my local environment.. But when am trying with the same code in digitalocean (SFTP) THROWS AN ERROR like

Could not establish FTP connection, invalid host or port.

please help me

  • check from digitalocean, the ip might be blocked by digitalocean firewall
    – fmsthird
    Feb 24, 2019 at 13:18
  • Did you ever find why ? I have currently the same pb (not with digital ocean), and the ftp_connect works on an external script, on the same server... Apr 15, 2020 at 14:52


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.