Why is my WordPress asking for FTP credentials?

So you faced it – your WordPress is suddenly asking you for your FTP credentials – whether it is during the plugin installation or WordPress update, you haven’t expected this. Why is WordPress asking for such an information? The answer is that the engine which is trying to create new files on your server’s drive is not able to do this or is not sure if this is possible. There is a simple solution which should work in most cases – we can simply let WordPress know that files can be written directly to the servers drive – in order to do this you should adjust wp-config.php file. The wp-config.php file is typically located in root folder of WordPress installation.

Open the file with the text editor and add this line at the end of the file:

define('FS_METHOD','direct');

Once updated, save the file and reload the page you were using when you were asked for FTP credentials.

This is required because WordPress have to reload the configuration in order to try to access your server’s drive directly. Hopefully, this trick will work. In most cases it does.

This is not working, what else I can do?

There is a chance that the engine is still not able to write to your server’s drive. This is the case when permissions to the files and directories are not properly set. The problem is that you should not mess with your files and directories permissions if you are not sure what you are doing. By changing these permissions you can leave your WordPress installation open to being exploited. If you are thinking that this can be the solution for you, you can try the following adjustments – please note that there is no easy way to revert these changes!

In order to change the ownership of WordPress installation directory to www-user (works in various Linux distributions):

sudo chown -R www-data:www-data /var/www/[wordpressInstallationDirName]

In order to allow the engine to write to the WordPress directory:

sudo chmod -R g+w /var/www/[wordpressInstallationDirName]

The above commands should help you set permissions to your WordPress installation, but as I stated before, this is not preferred solution. You can read more on the following pages:

5 Replies to “Why is my WordPress asking for FTP credentials?”

Leave a Reply

Your email address will not be published. Required fields are marked *