keepcalculator

06 Numbers and Powers

Fix WordPress Asking for FTP Credentials

Card No. 06·17027 · Updated · Standard formula, shown below

If WordPress asks for FTP credentials every time you try to install a plugin, theme, or update, it means the web server cannot write directly to your site’s files. This guide shows you how to fix that by adjusting your wp-config.php file, changing file permissions, or updating your hosting setup—no advanced coding skills required.

What You’ll Need

  • Access to your WordPress files via an FTP client (like FileZilla) or your hosting file manager.
  • Your hosting control panel login (cPanel, Plesk, or similar).
  • A text editor (like Notepad++ or VS Code) to edit files.

Step-by-Step

  1. Back up your site. Before changing anything, download a full backup of your WordPress files and database. Most hosting panels offer a backup tool, or you can use a plugin like UpdraftPlus.
  2. Connect to your server. Use an FTP client or your hosting file manager to navigate to the root folder where WordPress is installed (usually public_html or www).
  3. Edit wp-config.php. Locate the file named wp-config.php in the root folder. Download it to your computer, open it in a text editor, and add the following lines just before the line that says /* That's all, stop editing! Happy publishing. */:
    define('FS_METHOD', 'direct');

    This tells WordPress to write files directly using the PHP process, which usually bypasses the FTP prompt.

  4. Upload the edited file. Save the file and upload it back to the server, overwriting the original. If you used the file manager, you can edit the file directly from the panel.
  5. Test the fix. Go to your WordPress admin dashboard and try to install a plugin or update a theme. If it works, you’re done. If not, proceed to the next step.
  6. Check file permissions. If the FTP prompt persists, the server may not have write permission to the folders. In your FTP client or file manager, select the wp-content folder and set its permissions to 755 (directories) and 644 (files). Do the same for the wp-content/plugins and wp-content/themes folders. Avoid using 777 as it’s a security risk.
  7. Change ownership (if you have SSH or cPanel). In cPanel, use the “File Manager” > “Select All” > “Change Permissions” to set folders to 755 and files to 644. If you have SSH access, run chown -R youruser:yourgroup /path/to/wordpress to ensure the web server user owns the files.
  8. Disable FTP in wp-config (alternative). If the above doesn’t work, you can add the following lines to wp-config.php to force WordPress to use FTP with your credentials, but this is a temporary workaround:
    define('FTP_HOST', 'ftp.yourdomain.com');
    define('FTP_USER', 'your_ftp_username');
    define('FTP_PASS', 'your_ftp_password');

    Replace the placeholders with your actual FTP details. This is less secure and should only be used until you fix the underlying issue.

  9. Contact your host. If none of the above works, your hosting provider may have a specific configuration (like a managed WordPress environment) that requires you to ask them to enable direct file writing. Many hosts disable it for security reasons, and they can guide you on the correct method.

Common Mistakes

  • Editing the wrong file. Make sure you’re editing wp-config.php in the root folder, not a subfolder or a backup copy.
  • Using 777 permissions. This makes your site vulnerable to hacking. Stick to 755 for folders and 644 for files.
  • Forgetting to clear cache. After making changes, clear your browser cache and any caching plugin (like W3 Total Cache) to see the effect.
  • Not backing up. If you make a syntax error in wp-config.php, your site may go down. Always have a backup.

Tips

  • If you’re on a managed WordPress host (like WP Engine or Kinsta), you usually don’t need to do this—they handle file permissions for you. Contact them first.
  • Use a child theme for customizations to avoid losing changes during updates.
  • Keep your WordPress core, themes, and plugins updated to minimize security risks.
  • If you frequently need to upload files, consider using a staging environment to test changes before going live.

Troubleshooting

If the FTP prompt still appears after adding the FS_METHOD line, check the following:

  • Syntax error: Ensure you placed the line exactly as shown, with single quotes and no extra spaces. A missing semicolon can break your site.
  • Server configuration: Some hosts (like shared hosting) may have PHP running as a different user than the file owner. The direct method only works if PHP can write to the directories. If not, you may need to use the ftpext or ssh2 method instead.
  • Plugin conflicts: Temporarily disable all plugins by renaming the plugins folder to plugins_old via FTP, then try again. If it works, reactivate plugins one by one to find the culprit.
  • Check error logs: Look at your server’s error log (often in cPanel under “Errors” or “Logs”) for any PHP warnings that might indicate why the direct write fails.
  • Try a different browser: Sometimes browser cache or extensions can interfere with the admin panel. Try incognito mode or a different browser.

Frequently Asked Questions

Why does WordPress ask for FTP credentials in the first place?

WordPress asks for FTP when it cannot write directly to your server’s filesystem. This usually happens on shared hosting where PHP runs as a different user than the file owner, or when file permissions are too restrictive.

Is it safe to add define('FS_METHOD', 'direct')?

Yes, it’s generally safe and widely used. However, it assumes your server is configured to allow PHP to write to the WordPress directories. If permissions are wrong, it could cause security issues, so always set proper permissions (755/644) and avoid 777.

What if I don’t have access to wp-config.php?

You should always have access via FTP or your hosting file manager. If you don’t, contact your hosting provider—they can make the change for you.

Can I use the FTP credentials method instead?

Yes, you can add the FTP constants to wp-config.php as shown above. But it’s a temporary fix and less secure because your password is stored in plain text. It’s better to solve the underlying permission issue.

Will this fix affect my site’s performance?

No, adding FS_METHOD does not impact performance. It only changes how WordPress handles file writes. Your site’s speed and functionality remain the same.

I’m on a VPS or dedicated server, what should I do?

On a VPS, you can easily change file ownership and permissions via SSH. Run chown -R www-data:www-data /var/www/html (adjust the user and path) and set permissions to 755/644. Then add the FS_METHOD line. If you’re unsure, ask your host for the correct user.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →