Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davale12's avatar

Getting Connection timed out with flysystem-ftp even when the file appears in FTP

We have some login in my project to put files in an FTP server, we are getting this error: ErrorException: ftp_fput(): Connection timed out in /var/www/vendor/league/flysystem-ftp/FtpAdapter.php:163.

Despite the error, the files are actually being uploaded to the FTP server. I don't know if we have to close the connection after every file upload. this is the configuration we have :

Storage::extend('ftp', function ($app, $config) {
            $adapter = new FtpAdapter(
            // Connection options
                FtpConnectionOptions::fromArray([
                    'host' => $config['host'],
                    'root' => $config['root'],
                    'username' => $config['username'],
                    'password' => $config['password'],
                    'port' => (int)($config['port'] ?? 21),
                    'ssl' => true,
                    'timeout' => 90,
                    'utf8' => false,
                    'passive' => true,
                    'transferMode' => FTP_BINARY,
                    'systemType' => null, // 'windows' or 'unix'
                    'ignorePassiveAddress' => null,
                    'timestampsOnUnixListingsEnabled' => false,
                    'recurseManually' => true
                ])
            );
            return new Filesystem($adapter);
        });
0 likes
6 replies
davale12's avatar

We are using league/flysystem-ftp "^3.0" with Laravel 9 and we already changed the configuration to return a FilesystemAdapter.

return new FilesystemAdapter( new Filesystem($adapter, $config), $adapter, $config ); 

but still getting the error

kokoshneta's avatar

*bump*

Did you ever figure this out? I’m seeing the exact same thing – file upload is successful, but immediate after uploading, ftp_fput() times out, regardless of the timeout limit specified…

1 like
logiciel.dsti's avatar

I have the exact same problem in Laravel 12. Anyone ever figured it out?

manuelebeh's avatar

For me, I just had to set ssl to false for it to work. Although I don't know if that's the best way to do it

Please or to participate in this conversation.