You go to update a plugin or the latest security patch for WordPress, but when you click update you’re prompted for FTP credentials. It can be frustrating and annoying, but it has (typically) a simple fix. This WordPress FTP error is frustration at its peak.
You’ll need access to your wp-config.php file and ssh access to your server. Two steps:
- Apache server — via terminal/command line run
sudo chown -Rf www-data:www-data /var/www/html
(or could just be /var/www; all depends on your directory structure) - (Optional) Add this line to your wp-config.php file:
define('FS_METHOD', 'direct');
The first step is giving the process www-data ownership permissions to update all files/directories without FTP access. Typically Apache servers run as www-data or sometimes httpd. To verify/determine your server’s setup, run ps aux | grep apache
or ps aux | grep httpd
.
The second step is to force WordPress to use the File System method of downloading/uploading files for updates. Only set this if step #1 doesn’t fix your FTP credential issue. For more information regarding the FS_METHOD, read this.
And you should now be done. I hope that helped.
I also faced this error and I thought that the problem was in a plugin. Now, I understand that my thoughts were wrong about it. Anyway, thank you for this explanation.
Glad to help! Appreciate being able to explain the error in a succinct way.