Introduction
You click “Install Now” on a plugin and instead of installing, WordPress stops and asks: “To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed.” Every install, every update, every time. Most site owners don’t even have FTP credentials at hand — and the frustrating part is that WordPress usually doesn’t need them at all. In most cases, one line in wp-config.php makes this prompt disappear for good.
Why WordPress Asks for FTP Credentials
Before writing any file — a new plugin, a theme update, a core upgrade — WordPress checks whether it can create files on the server as the correct owner. It does this by writing a small temporary file and comparing who owns it.
If your WordPress files are owned by one system user but PHP runs as a different user (a very common setup on VPS and some shared servers), that ownership check fails. WordPress then refuses to write files directly and falls back to its safest alternative: asking for FTP credentials so it can make the changes over FTP instead.
So the prompt isn’t an error — it’s a symptom of a file ownership mismatch between PHP and your WordPress files. That’s also why it often appears suddenly after moving to a new host or after a server configuration change.
Fix 1: Tell WordPress to Write Files Directly (One Line)
Open wp-config.php in your site’s root folder (via your host’s File Manager or FTP) and add this line just above /* That's all, stop editing! */:
define( 'FS_METHOD', 'direct' );
Save the file and try installing a plugin again — the FTP prompt should be gone. This tells WordPress to skip the ownership check and write files directly using PHP.
Is it safe? On the vast majority of modern hosts — where each site runs PHP as its own user — yes, this is exactly how things should work. The one setup where you should not use it is a poorly configured server where PHP runs as a shared user (like www-data) across many sites: there, files created by PHP could be writable by other sites on the same box. If that’s your situation, use Fix 2 instead.
Fix 2: Fix the File Ownership (The Root Cause)
The proper long-term solution is making PHP and your files agree on ownership:
- On shared hosting: you can’t change this yourself — open a support ticket and tell them “WordPress asks for FTP credentials when installing plugins; please check that PHP runs as the same user that owns my files.” Hosts fix this routinely.
- On a VPS you manage: set the WordPress directory to be owned by the user PHP-FPM runs as, e.g.
chown -R www-data:www-data /var/www/yoursite(adjust user and path to your setup), and keep permissions at755for folders and644for files.
Fix 3: Store the FTP Credentials (Last Resort)
If neither option is available, you can at least stop typing the credentials every time by adding them to wp-config.php:
define( 'FTP_HOST', 'ftp.yoursite.com' );
define( 'FTP_USER', 'your-ftp-username' );
define( 'FTP_PASS', 'your-ftp-password' );
Be aware this stores your FTP password in plain text inside a file on the server — acceptable as a stopgap, but Fix 1 or 2 is always the better destination.
Frequently Asked Questions
Why did this start suddenly when everything used to work?
Almost always a hosting change: you migrated servers, your host changed how PHP runs, or file ownership was altered during a restore or manual upload. The mismatch is new — the prompt follows.
I entered my FTP credentials and it still fails — why?
Check that the hostname is right (often localhost works, since WordPress is connecting to its own server), and that your server actually runs an FTP service. Note that plain WordPress supports FTP and FTPS here, but not SFTP — if your host is SFTP-only, use Fix 1 or 2 instead.
Is FS_METHOD direct a security risk?
Not on a properly configured host where your site’s PHP runs as your own user — which is the standard on reputable shared hosting today. If you’re unsure, ask your host: “Does PHP run as my account’s own user?” If yes, you’re fine.
Could this prompt mean my site was hacked?
The prompt itself, no — it’s a permissions symptom. But if file ownership changed without any hosting change you know of, it’s worth a quick check — see our guide to checking and fixing a hacked WordPress site.
Conclusion
The FTP credentials prompt is WordPress being cautious about a file ownership mismatch — not a broken site. On most hosts, define( 'FS_METHOD', 'direct' ); in wp-config.php ends it in one line; on misconfigured servers, fixing the actual ownership is the clean cure. Either way, you should never need to hunt down FTP credentials just to update a plugin again. And before editing wp-config.php, the usual rule applies: take a quick backup first.
Edit config files without fear
Nota Backup & Restore keeps a fresh snapshot of your files and database, so any server-side tweak is a one-click rollback away. Start your 14-day free trial — no credit card required.
