Update Failed: Failed to connect to FTP Server 127.0.0.1:21
WordPress Plugin Update Failed | Failed to connect to FTP Server 127.0.0.1:21
While updating plugin if you encounter the error “Update Failed: Failed to connect to FTP Server 127.0.0.1:21“, than you can try the following solution:
Check File permissions
All directory should have 755 permission and should be owned by the user running the appropriate user.
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data username
Change FS_METHOD to “direct”
In wp-config.php file change FS_METHOD to “direct”
define('FS_METHOD', 'direct');
Remove Bitnami configuration
If you have migrated your wordpress site from bitnami to self hosted website than remove the following piece of configuration from wp-config.php and restart the php-fpm and webserver(nginx).
/*define('FS_METHOD', 'ftpext');
define('FTP_BASE', '/opt/bitnami/apps/wordpress/htdocs/');
define('FTP_USER', 'bitnamiftp');
define('FTP_PASS', 'XXXXXXXXXXXXXXXXXXXXXXXXX');
define('FTP_HOST', '127.0.0.1');
define('FTP_SSL', false);
*/