Are you bent out of shape right now, trying to fix the “Enter FTP credentials to proceed” error in WordPress?

wordpress-asking-for-ftp-credentials

Often times, this error occurs when the user doesn’t have the required permissions to write to a specific directory that WordPress is intending to create.

So, to solve this issue, you can either add your FTP credentials in the WordPress ‘wp-config.php’ file or you can add a code that overrides the permission required by WordPress to update a plugin or a theme.



Solution 1: Adding FTP credentials

If you don’t know your FTP credentials, go with Solution 2.

Assuming you have your FTP credentials with you, follow these steps:

1. Log in to your web hosting panel and go to ‘File Manager‘ / If you’re in localhost, go to your Web server stack (XAMPP/LAMPP) folder -> ‘htdocs‘ folder.

2. Open the ‘public_html‘ folder / If you’re in localhost, open your main WordPress directory.

public_html
^ Web host ^
^ Local host ^

3. Locate the ‘wp-config.php‘ file.

wpconfig

4. Open ‘wp-config.php’ and add the following code at the end of the file:

define('FTP_USER', 'my-ftp-username');
define('FTP_PASS', 'my-ftp-password');
define('FTP_HOST', 'ftp.my-site.com');

Don’t forget!

Make sure to change the ‘my-FTP-username’, ‘my-FTP-password’, ‘ftp.my-site.com’ fields to your own FTP credentials before adding them to the wp-config.php file.
wpconfig 2

5. Save and close the file.

That’s it.

Now, go back to WordPress and try installing/updating the plugin now.

The problem should be fixed.

If this solution didn’t work, try Solution 2.


Solution 2: Overriding the permission

1. Log in to your web hosting panel and go to ‘File Manager‘ / If you’re in localhost, go to your Web server stack (XAMPP/LAMPP) folder -> ‘htdocs‘ folder.

2. Open the ‘public_html’ folder / If you’re in localhost, open your main WordPress directory.

public_html
^ Web host ^
^ Local host ^

3. Locate the ‘wp-config.php’ file.

wpconfig
4. Open ‘wp-config.php’ and add the following code at the end of the file:

define('FS_METHOD','direct');
wpconfig 3

5. Save and close the file.

That’s it.

Now, go back to WordPress and try installing/updating the plugin now.

The problem should be fixed.

Note: If the “WordPress asking FTP credentials” error is solved, but now you’re getting the error “Installation failed: Could not create directory“.

Installation failed

Follow the below steps below to fix it.


How to fix the error: “Installation failed: Could not create directory”

Similar to the previous error, this error occurs because the user still doesn’t have the required permissions to install/update the plugins in WordPress.

The following solution will fix the error.

If you’re using localhost:

1. Go to your Web server stack (XAMPP/LAMPP) folder -> ‘htdocs‘ folder.

2. Locate and open your terminal inside the WordPress directory

How to open terminal in Mac: Single-click on the folder where you wish to launch a Terminal window, click on “Finder” followed by “Services,” and select “New Terminal at Folder.”

How to open terminal in Linux: Right-click on the folder where you wish to launch a Terminal window, click on “Open in Terminal”.

and use the following commands one by one:

sudo chown -R www-data:www-data wp-content/plugins/
sudo chmod 775 wp-content
sudo chown -R www-data:www-data wp-content/

The error “Installation failed: Could not create directory” should be now fixed.

If you’re using web hosting:

1. Log in to your web hosting panel and go to ‘File Manager‘.

2. Open the ‘public_html’ folder.

3. Right-click on the ‘wp-content‘ folder and select ‘Permissions’.
wpcontent permissions

4. Make sure the number shown there is “755” and the boxes are checked as shown in the image below:

755

5. Save the changes and that’s it.

The error should be fixed now.

This error is pretty common when you’re using localhost for your WordPress website.

Changing the permission, as shown above, will fix the error instantly.

If you still have some doubts, comment below and let me know. I’ll be sure to help.