{"id":5966,"date":"2020-12-05T13:57:19","date_gmt":"2020-12-05T08:27:19","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=5966"},"modified":"2026-11-20T12:22:18","modified_gmt":"2026-11-20T06:52:18","slug":"when-you-try-to-install-the-plugin-in-wordpress-site-it-asks-for-ftp-credentials","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/when-you-try-to-install-the-plugin-in-wordpress-site-it-asks-for-ftp-credentials\/","title":{"rendered":"When you try to install the plugin in wordpress site it asks for FTP credentials"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> December 5, 2020<br><strong>Last Updated:<\/strong> November 20, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains how to fix the problem when <strong>WordPress asks for FTP credentials<\/strong> while you install a plugin or update a theme. WordPress shows the FTP form when it cannot write to its own folders. The real fix is usually a file ownership change, not an FTP account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original guide told you to add <code>FS_METHOD<\/code> to <code>wp-config.php<\/code> and run <code>chmod -R go+w wordpress<\/code>. The second command makes every file writable by the group and by all other users, which is a security risk. This version fixes the ownership instead, keeps <code>FS_METHOD<\/code> as a fallback, and adds checks, exact error messages and troubleshooting.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Warning:<\/strong> If WordPress asks for FTP credentials, don&#8217;t get past it with <code>chmod 777<\/code> or <code>chmod -R go+w<\/code>. Writable files let a compromised plugin, or another account on the server, change your site. Back up <code>wp-config.php<\/code> and your site files first.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you fix the screen where WordPress asks for FTP credentials, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SSH access with sudo privileges<\/li>\n\n\n\n<li>The path of the WordPress folder, for example <code>\/var\/www\/html\/wordpress<\/code><\/li>\n\n\n\n<li>A WordPress administrator login to test the install<\/li>\n\n\n\n<li>A backup of <code>wp-config.php<\/code> and your site files<\/li>\n\n\n\n<li>Knowledge of the user your web server runs as (Step 1 shows how to find it)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>WordPress writes a temporary file inside <code>wp-content<\/code> to test whether it can change files directly<\/li>\n\n\n\n<li>It compares the owner of that file with the user that runs PHP (Apache, or PHP-FPM with Nginx)<\/li>\n\n\n\n<li>If both are the same user, WordPress uses direct file access and installs plugins without asking<\/li>\n\n\n\n<li>If the owners differ, WordPress falls back to FTP and shows the form<\/li>\n\n\n\n<li>The <code>FS_METHOD<\/code> constant in <code>wp-config.php<\/code> skips that test, while correct ownership makes the test pass on its own<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The image below shows the check. For the official references, see the WordPress developer guide to <a href=\"https:\/\/developer.wordpress.org\/advanced-administration\/wordpress\/wp-config\/\" target=\"_blank\" rel=\"noopener\">editing wp-config.php<\/a> and the guide to <a href=\"https:\/\/developer.wordpress.org\/advanced-administration\/server\/file-permissions\/\" target=\"_blank\" rel=\"noopener\">file permissions<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic-1024x683.png\" alt=\"\" class=\"wp-image-13701\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic-1024x683.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic-300x200.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic-768x512.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic-272x182.png 272w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix-Infographic.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Steps When WordPress Asks for FTP Credentials<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Find the Web Server User<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ps aux | grep -E 'apache2|httpd|nginx|php-fpm' | grep -v root | head -5\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The user is usually <code>www-data<\/code> on Debian and Ubuntu, <code>apache<\/code> on RHEL-based systems, and <code>nginx<\/code> for some Nginx setups. On cPanel or Plesk servers, PHP often runs as the account user, so use that account name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Back Up and Undo Unsafe Permissions<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/var\/www\/html\/wordpress\nsudo cp wp-config.php wp-config.php.bak\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you already ran <code>chmod -R go+w<\/code> from the old guide, remove that permission:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo chmod -R go-w \/var\/www\/html\/wordpress\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Set the Correct Ownership and Permissions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This is the main fix when WordPress asks for FTP credentials. Replace <code>www-data<\/code> with the user from Step 1:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo chown -R www-data:www-data \/var\/www\/html\/wordpress\nsudo find \/var\/www\/html\/wordpress -type d -exec chmod 755 {} \\;\nsudo find \/var\/www\/html\/wordpress -type f -exec chmod 644 {} \\;\nsudo chmod 640 \/var\/www\/html\/wordpress\/wp-config.php\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now open <strong>Plugins<\/strong>, then <strong>Add New<\/strong>, and try the install again. In most cases the FTP form is gone.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Add FS_METHOD Only If the Form Still Appears<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open <code>wp-config.php<\/code> and add this line above the comment that says &#8220;That&#8217;s all, stop editing!&#8221;:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">define( 'FS_METHOD', 'direct' );\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The original guide placed it after <code>DB_COLLATE<\/code>, which also works, as long as it comes before that comment. Type the quotes by hand or copy them from the code block. Curly quotes copied from a web page break PHP.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <code>FS_METHOD<\/code> only tells WordPress to skip the ownership test. If PHP still can&#8217;t write to the folders, the install fails with &#8220;Could not create directory&#8221;, so Step 3 is still needed.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">5. Test and Verify<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Install a plugin and confirm that no FTP form appears. You can also check write access from the terminal:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -ld \/var\/www\/html\/wordpress\/wp-content\/plugins\nsudo -u www-data touch \/var\/www\/html\/wordpress\/wp-content\/plugins\/test.tmp &amp;&amp; echo writable\nsudo rm \/var\/www\/html\/wordpress\/wp-content\/plugins\/test.tmp\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the dashboard, <strong>Tools<\/strong>, <strong>Site Health<\/strong>, <strong>Info<\/strong>, <strong>Filesystem Permissions<\/strong> shows which folders WordPress can write to.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If WordPress still asks for FTP credentials after the fix, check these:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&#8220;To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed.&#8221;:<\/strong> The folder owner and the PHP user still differ. Repeat Steps 1 and 3 with the correct user<\/li>\n\n\n\n<li><strong>&#8220;Installation failed: Could not create directory.&#8221;:<\/strong> <code>wp-content<\/code> or <code>uploads<\/code> is not writable. Check ownership, free disk space with <code>df -h<\/code>, and the SELinux note below<\/li>\n\n\n\n<li><strong>WordPress still asks for FTP credentials after you change the owner:<\/strong> PHP-FPM may run under a different user than the web server. Check the <code>user =<\/code> line in your PHP-FPM pool file, and use that user in Step 3<\/li>\n\n\n\n<li><strong>A &#8220;Parse error: syntax error&#8221; page after editing <code>wp-config.php<\/code>:<\/strong> The edit has curly quotes or a missing semicolon. Restore <code>wp-config.php.bak<\/code> and add the line again<\/li>\n\n\n\n<li><strong>&#8220;Unable to locate WordPress Content directory (wp-content).&#8221;:<\/strong> WordPress is trying FTP with wrong details. Fix the ownership instead of entering FTP details<\/li>\n\n\n\n<li><strong>SELinux blocks writes on RHEL-based systems:<\/strong> Set a writable context on <code>wp-content<\/code>, then restore it:<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo semanage fcontext -a -t httpd_sys_rw_content_t \"\/var\/www\/html\/wordpress\/wp-content(\/.*)?\"\nsudo restorecon -R \/var\/www\/html\/wordpress\/wp-content\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When WordPress asks for FTP credentials, the cause is almost always a mismatch between the file owner and the PHP user. Find the web server user, set it as the owner, use 755 for folders and 644 for files, and add <code>FS_METHOD<\/code> only if the form persists. Avoid <code>chmod 777<\/code> and <code>go+w<\/code>, since they fix the symptom by weakening your site&#8217;s security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions (FAQs)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why does my site show a screen that asks for FTP credentials?<\/strong><br>WordPress could not write a test file as the user that runs PHP. When the file owner and the PHP user differ, it assumes it needs FTP to change files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Is <code>define( 'FS_METHOD', 'direct' );<\/code> safe?<\/strong><br>It is safe when the ownership is already correct, because it only skips the check. It does not grant write access, so it will not fix a permission problem by itself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Should I use <code>chmod 777<\/code> or <code>chmod -R go+w<\/code> instead?<\/strong><br>No. Both let other users on the server modify your files. Use <code>chown<\/code> with 755 for folders and 644 for files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do I need an FTP account for plugin installs?<\/strong><br>Not on a server where you control ownership. Direct file access works once the file owner matches the PHP user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-block-ips-via-htaccess-file\/\">How to Block IPs via .htaccess File<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-add-a-new-domain-in-the-directadmin-panel\/\">How to Add a New Domain in the DirectAdmin Panel<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to Our Technology Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Worried about insecure file permissions on your WordPress server? Our team can correct ownership, lock down write access, and harden your hosting environment through our <a href=\"https:\/\/pheonixsolutions.com\/security\/\">Security Services<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"> <\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: December 5, 2020Last Updated: November 20, 2026 Introduction This guide explains how to fix the problem when WordPress [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13702,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[185,789,167],"class_list":["post-5966","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-architecture","tag-ftp-2","tag-plugin-installation","tag-wordpress-2","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1ye","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/WordPress-FTP-Credentials-Fix.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5966"}],"version-history":[{"count":4,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5966\/revisions"}],"predecessor-version":[{"id":13707,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5966\/revisions\/13707"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/13702"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}