Unable to install plugins on localhost

When creating WordPress websites I like to do so locally (e.g. XAMPP). Working locally has allot of advantages like faster load speed, being able to load the entire project in the IDE of your choice (code suggestion for your entire project) and the ability to use versioning software (like SVN and GIT). The only problem I had was not being able to install plugins from within the plugin backend page.

Searching through the plugin repository works fine but when you try to install a plugin you’re asked to enter FTP credentials to proceed (the ‘Connection Information’ screen). And because we’re working locally, it’s most likely that we don’t have FTP access to our local server.

Connection Information Screen

Connection Information Screen

Of course you can download the plugin from the wordpress.org online repository and then copy the files to your local plugin directory, but you don’t have to! We can simply add the following code to our wp-config.php to let WordPress use a different filesystem method than FTP.

define('FS_METHOD', 'direct');

Setting the ‘FS_METHOD’ to ‘direct’ will also allow you to update WordPress Core and install themes from the theme repository locally. I’d love to know if this helped you or if you have a question, so please leave a comment below.

Related Posts

Powered By Related Posts for WordPress
Click Here to Learn More About Related Posts for WordPress

231 thoughts on “Unable to install plugins on localhost

  1. Can’t remember where I found this, but this works for me too:

    if(is_admin()) {
    add_filter(‘filesystem_method’, create_function(‘$a’, ‘return “direct”;’ ));
    define( ‘FS_CHMOD_DIR’, 0751 );

  2. I also get this problems but now problem solved thanks for sharing

  3. This is a great solution. Thanks.

  4. Hi,

    I entered the line of code exactly as you said in the wp-config.php file underneath the other “defines” but when I go to download a plugin, instead of being asked for FTP credentials (as I did previously), I now get this message:

    Installing Plugin: Advanced YouTube Embed With Google Analytics -like Stats, by Embed Plus 2.6
    Downloading install package from http://downloads.wordpress.org/plugin/embedplus-for-wordpress.2.6.zip…

    Unpacking the package…

    Could not create directory. /Users/RichM/Sites/wordpress/wp-content/upgrade

    Return to Plugin Installer

    Do you know how I can fix this!?!? Thanks!!

    • i think its cause of your folder permissions. Set them all to 777 and you wont get this error again

      • looks like this is the root of the entire problem, if the folder permissions are correct in the first place then the configuration change is not needed on my install

      • thanx!!!

      • timmy_leur@hotmail.com

        Plz, never ever put the file permissions on 777, this will make it accessible to the public. Make sure the user (who runs the apache service) has the read/write permissions on the wp-content folder.

    • you may also chown to your apache account :

      chown www-data:www-data -R you_publishing_directory

      • Lau Dam Mortensen

        Hi, thanks Baobab33. It worked for me.
        I just typed

        chown www-data:www-data -R /var/www/html

        which is the default publishing directory for your server on ubuntu.

  5. Update on this:

    In terminal I changed the privileges for the wp-content folder and the plugins folder to 777. Plugins now install perfectly.

  6. Yes. Finially. So many bad suggestions out there… You are the best, thanks!

  7. Thanks a looooot

  8. Thanks a ton for sharing this info .

  9. Gustavo M. Severo

    I tried to change all defines() in my wp-config.php and when I back to my local wordpress, appears a page saying: “Error to connect the database…. It means that the user and password informations in your wp-config.php are incorrects”.

    What, exactly I have to do?

    Thank you for your attention guys.

  10. Thanks for the easyfix!

  11. This worked great, Barry. Thank you.

  12. Thanks for the tip Barry, it worked beautifully.

  13. THANKS.. wonderful solution!

  14. David Gross

    Find the wp-config.php in word press folder

    Put this at the bottom of the code.
    define(‘FS_METHOD’, ‘direct’);
    /* Allows for wordpress plugins to work on localhost */

    Then open your terminal and navigate to your worpress content folder site.
    Mine is:
    cd Sites/wordpress/wp-content

    Once there type in this code and plugins should work fine
    chmod -R 777 plugins

    • For those of you that are frightened at the thought of using terminal, you can also navigate to your directory through finder and change the files manually to read & write in the wp-content folder.

      • You must first change wp-content, then “plugins”, “themes”, and there’s one more in there I can’t remember. Hope this helps!

    • Hi, I am a total WordPress beginner and also have the problems installing the plugins on my localhost. I already tried all your advices but absolutely don´t know where and how to change the permissions. I work on an apple system with XAMPP. Can you help me please!

    • How do i get to my terminal

  15. Muchísimas gracias, muy útil tu información. Me sacó de apuros!.

  16. Mark Hardiek

    After one hundred incorrect suggestions, yours worked. Thanks man!

  17. Barry, this was such an elegant fix—thank you!

  18. Ashley Doyle

    Hi Barry (and others who may want to post the fix).

    When I add this line to the wp config file I no longer get the option to install or delete plugins. All I can do is active the plugins that are already installed.

    Is there a work around for this, or have I done something else wrong?

  19. mittul agile

    this is THE BEST solution ever. thanks a many lott . .:)

  20. Thanks for this,

    I also get the error: Could not create directory.
    when updating Core or plugins.
    Im not happy about changing permissions to 777 as I dont want my wordpress installation to become a spam hijacked site.

    Any ideas? 755 even has issues

  21. Mohammad Haidar

    Thank you so much , very helpful article.

  22. Fra' Cercone

    Thanks a lot!!!!!
    I lost an awful lot of time in search of a solution, and your suggestion worked just fine.

  23. Thanks a lot! Worked like a charm 😉

    I just have one question though. Do I have to remove/comment this line in wp-config.php file when I move the wordpress installation to external server (not localhost anymore)?

  24. Thank you for share a nice Tips with us. It works perfectly!

  25. Awesome!!! i’ve been looking the solution to this problem for hours!!!

    Thanks a lot!!

  26. Thanks for sharing this, highly appreciated!

  27. Thanks a lot Barry…. this totally helped me out… I was about to do a manual installation.. 🙂

  28. after putting in that line in wp-config and changing the permissions, i still can’t install plugins. it says it can’t create the directory. any help would be appreciated.

    • EDIT: i just manually put the plugin into the directory. but if someone can still fix my issue that’d be great. thanks.

  29. Thanks alot! Just what I was lookin for.

  30. Thanks a lot Barry, it perfectly works on my localhost wordpress 🙂

  31. Hi Barry. When we want to transfer the local site back to the live site after using this method,
    I’m guessing we need to remove define(‘FS_METHOD’, ‘direct’); correct?

    Does anything else need to be done to the wp.config file to make the live environment work properly?

  32. Yes, remove the define(‘FS_METHOD’, ‘direct’); on the live website.

    Does anything else need to be done to the wp.config file to make the live environment work properly?

    Set WP_DEBUG to false 🙂

  33. Hi Barry,

    I run wp with wamp on localhost, i get these error when i try to install wootique and woocommerce plugin:

    Fatal error: call to a member fuction get_cart_url on a non-object in c:\wamp\www\mysite .. On line 197 call stack

    I ve searched forunms for solution to no avail, please kindly help out with a solution. Thanks

  34. Thank you. You saved me many hours of time!

  35. Thanks a lot !

  36. so this issue showed up for me after moving my install to a diff DIR
    after making the change you recommended i was faced with the permissions error as well. This made me realise that the FTP prompt was not because of the missing setting but because of the folder permissions. removed the setting you recommended and the corrected the folder permissions for the plug in dir and TADA all working as expected.

    Thanks for taking the time to post this though as it did get me on the right path!

  37. Terimakasih banyak atas solusinya 🙂
    (thanks very much)

  38. I LOVE YOU Man 😀 Perfectly Solved The Issue !!!!

  39. Man, i love you!!!,

    So thank you !! 🙂

  40. Great fix, thank you !!!! It was getting really annoying to have to download unpack and copy every theme and plugin.

  41. Aashish Ghale

    Worked for me. 🙂

  42. Hi Barry,

    I am a noob in wordpress and recently i am developing a site in wordpress which needs a gallery, however when i try to download the jetpack plugin i get this error: ” Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\wordpress\wp-includes\class-http.php on line 1589″

    Please help!


  43. thank u very much.


    i. Open the wp-config.php files
    ii. copy & paste line: define(‘FS_METHOD’, ‘direct’);

    Fixed! 🙂

  44. Zeeshan Asif

    Now it says “Could not create directory.”

  45. thank you so much barry. i had being looking for the solution a couple of days now.

  46. Paulo Colaço

    Thank you Barry!
    I was getting one trouble after another using several sites with xampp on mac, because wordpress wouldn’t install plugins and themes, when I did it manually some of them wouldn’t be recognized.
    Great help, thanks again.

  47. Hello 🙂 I am trying to install the plugins but I am unable to do so. I plugged in the code and now I am getting the error message that some people seem to be getting also.

    I do not understand how to do the 777 code on the terminal, do you mind walking me through on how to do that please?

    I need to build this site offline because there’s one currently live already.

    Thank you in advance!

    • Hi Lorena, you know what..

      i almost 4 hours try to find how can i understand “777 code on terminal”..
      i hope this is work for u :

      go to terminal and type this

      chmod -R 777 /Applications/XAMPP/htdocs/

      this is work for me

  48. Thanks dude!

  49. Just found your post and was immensely helpful! Just a flag to errbody though — don’t leave your permissions at 777!! Major security issue. Set back to 755 after you’ve downloaded your plugins.

    Thank you!!

  50. Dude, You’re a genius! Thanks for sharing.

  51. Very thanks this article solve my problem

  52. Thanks, Worked 🙂

  53. Many thanks, very useful, worked for me fine.

  54. Thanks your solution helped!
    had the same problem

  55. Great solution! Thanks 😉

  56. Dude.

    You rock.

    Thanks a million for saving me a bundle of time.

  57. This was very useful!

    I use my home server for testing and staging. This made everything easier.

  58. Thanks bro! It works really well!

    But i have another problem, after it pass that page.
    All the installation of the plugin become failed.

    Do you have any idea why?

    • Barry Kooij

      Sounds like a permission issue. Try changing the file/dir right to 777 on your local system. Remember to not do this on your live website!

  59. John Hobson

    Great – thanks very much! Worked a treat

  60. i cant change permission to 777

  61. Exactly what I was looking for, thank you sir.

  62. My problem has been solved, thank’s bro.

  63. Cheers!! Jobs a a good’n!!

  64. It’s not good 4 me…

    chmod: Unable to change file mode on /Applications/XAMPP/htdocs/: Operation not permitted

    what should I do?

  65. Beautiful. Thank you so much!

  66. Thank you so much!

  67. Thanks. It worked for me.

  68. it’s not work using wordpress 4.4.1

  69. Excelent !!!

  70. This is my version of this fix. Just ensuring that noone takes advantage of this unless they are administrators.

    if(is_admin()) {
    define(‘FS_METHOD’, ‘direct’);

  71. Worked like a charm 🙂

  72. Ilse Domínguez

    Thank you SO much!
    Spent weeks looking for this answer!
    Much love <3

  73. I had to change the owner/group owner of the files on my site for this to work (it gave me the error message ‘cannot create directory’ and I spent a lot of time searching for this solution).

    In a terminal, enter:

    cd insert_pathname/insert_sitename

    Then enter:

    sudo chown -R www-data:www-data *

    You will need to enter your password.

    In case you don’t know what you just did:

    First line:
    cd = move directory
    insert_pathname = where your site is stored locally
    / = separator
    insert_sitename = name of your site

    Second line:
    sudo = grant super user permission
    chown = change the file ownership
    -R = go through all sub directories
    www-data = change owner
    : = separator
    www-data = change group ownership
    * : act on all files

    ‘www-data’ will allow wordpress to make directories and amend files.

    Hopefully that will help others!

  74. Oh and make sure you do actually change directory (first line) before doing the second line as that will mess up the directory you are in, trust me I know this from experience!

  75. Just started with WordPress today on localhost and immediately ran into this problem.

    Thanks for sharing.


  76. This is also possible if they offer SEO as part of their service.
    A dedicated rented machine can be rented for operating complex web applications and for the multiple sites interconnected to your business.

    There are thousands of web-hosting service providers and all of them
    claim to be the best.

  77. Awesome! Worked perfectly fine. Although had to chown to _www (I’m on a Mac)

  78. ahmed salah


  79. thanks just what i needed worked perfectly

  80. Thanks its great

  81. Thanks, it did helped.

  82. ok terimakasih, berhasil

  83. What’s up to every one, for the reason that I am genuinely eager of reading this webpage’s post to be updated regularly.
    It includes pleasant material.

  84. I uploaded free theme from internet to my localhost and i want to upload its plugins and i face this problem,

    “Warning: an unexprected error occured. something may wrong with wordpress.org or the this server’s configuration. if your continue to have problems, please try the support forums (wordpress could not establish a secure connection to wordpress.org Please contact your server administrator.) in C:\xampp\htdocs\wordpress\wp-admin\includes\plugin-install.php on line 158.

    something went wrong with the plugin APl. “

  85. I uploaded free theme from internet to my localhost and i want to upload its plugins and i face this problem,

    “Warning: an unexprected error occured. something may wrong with wordpress.org or the this server’s configuration. if your continue to have problems, please try the support forums (wordpress could not establish a secure connection to wordpress.org Please contact your server administrator.) in C:\xampp\htdocs\wordpress\wp-admin\includes\plugin-install.php on line 158.

    something went wrong with the plugin APl. “

  86. Monti Chandra

    Thanks for the tip Barry.

  87. Kevin Winks

    Yep Still helpful 3+ years on, a real novice might struggle to find the location of the file to edit… this is where i found it in mine:


    opened with notepad:

    added the following line, so I know what it is in the future:

    //** File system Setting – adding the following changes the file system from ftp to direct for local hosts */
    define(‘FS_METHOD’, ‘direct’);

    But ultimately without your tip Barry Kooij I’d have been scratching my head for weeks so thank you

  88. Amazing issues here. I am very satisfied
    to see your post. Thanks so much and I am taking a look ahead to touch you.
    Will you kindly drop me a e-mail?

  89. Hi it’s still not work for me it appears like this :
    Downloading install package from https://downloads.wordpress.org/plugin/bootstrap-shortcodes.3.4.0.zip…

    Unpacking the package…

    Could not create directory.

    Anyone come up with solution? Thanks before

  90. Dariel Lucas

    Thank for you useful solution!

  91. Loving the info on this web site, you have done outstanding job on the posts.

  92. Worked. Thank you.

  93. Worked here.

    upgraded to wordpress 4.6.1 using ubuntu 16.04 desktop version.

    just check if site folder have the right owner and permissions

    sudo chown www-data:www-data /path/to/folder
    sudo chmod g+w /path/to/folder

  94. Azhar Munshi

    Thank you Berry 🙂 🙂

  95. I have already installed plugins on localhost. Thanks for help!

  96. helps me everybody
    i have a bootstrap to wordpress converted but can’t install any plugin what can do that
    if need bootstrap portfolio web site go the blew link

  97. thx bud. works out of the box, so to speak.

    kinda ridiculous that WP wouldn’t address this in documentation, as most developers would work on localhost environment prior to uploading to FTP.

    yours is a save in the bottom of the ninth.

    nice going. thanks again.

  98. I think this is one of the most important info for me. And i’m glad reading your article.
    But should remark on few general things, The site style is ideal, the articles is really great :
    D. Good job, cheers

  99. Frustated for a couple hours. And try that’s code. It’s work.
    Thanks for make my life easier.

  100. perfecto !

  101. Thank you so much Barry!
    Everything works now thanks to your codeline in wp-config, plus I spend a lot of time trial and error giving maps write and read permissions manually.

    The 777 thing I just dont understand… Which terminal, thing are people talking about??

    I’m working on MacOSX version 10.6.4

    If I create another database and install another wp installation in the future, is there a written rule what to do about the read and write permissions to maps? E.g. if client-map in htdocs has permissions for write and read will maps inside this map copy those privileges?

  102. ps. love the dutch design of https://2016.netherlands.wordcamp.org
    beautifully done!!

  103. eranda ranasuriya

    works for me too. Thanks Barry

  104. Man that’s just groovy…THANKS A LOT, works like its charmed….

  105. My “cannot copy …” error was due to a too long pathfile. Since modified path, it woroked. If it helps someone …

  106. still i got this while download plugin
    Installation failed: Download failed. No working transports found

  107. Pretty cool. Thanks!

  108. Worked for me too!!!
    Thanks a lot..

  109. I also get this problems but now problem solved

    Thanks for Sharing

  110. Worked perfectly for me.
    Thanks very much

  111. Good post, keep

  112. No I I Did What U Reffer But I Still Getting (Internal Sever Error) Can u plzz Tell Me How To Fix This Error

  113. Thank you so much, it really helps me!!!

  114. Yep this made my life a little easier!
    Maybe it’s good to mention where the php file is found and that you need to reload the admin page before it works.

  115. Helpful thanks

  116. Hi, on occasion I get a 503 server message when I browse this site. Just a heads up, best wishes

  117. Haven’t worked on WordPress for years, and this always annoyed me – was fine doing it from the command line, but this is just easier.


  118. thanks

  119. Asraful Haque


  120. Anurag Jain

    I works for me!

  121. Reply

  122. Worked for me. Thanks a lot.

  123. Ravi Maurya

    It Works.Thanks…

  124. Oh my! Bless you! Every time I updated my plugins I got stuck during the process and just every once in a while it worked.
    Adding this one line of code fixed the problem straight away! Thanks!

  125. When I originally commented I seem to have clicked on the -Notify
    me when new comments are added- checkbox and from now on each time a comment is added I
    get 4 emails with the same comment. There has to
    be a way you can remove me from that service? Thank you!

  126. Thanks a lot mate

  127. Awesome. Thank you.


  129. For me, setting maximum execution time in php.ini helped solve the problem (initially it was set to just 30s):
    max_execution_time = 120

    First I got 500 Internal Server Error, but then I went to this link to see full install log and saw that max exec time was making problems:

    Hope it helps someone!

  130. holy crap. it’s working for me. i have honestly considered going back to windows (now using mac) because i couldn’t get this to work, and on windows xampp this is all automatically done. wow. thanks a lot.

  131. Andrew Kibor

    Works for me.

  132. Excellent! Thanks!

  133. Sometimes things in the comments or in the article work.. but if don’t.. then just give it what it asks for 🙂 localhost/ root/ empty password .

  134. Thanks, work perfectly.


    Thanks a lot.

  136. I fount the solution! And of course it works like a charm!

    1. Open Terminal and type: sudo nano /etc/hosts
    2. Enter your Mac’s password
    3. Add following line to your hosts file: api.wordpress.org
    4. Save your hosts file and restart MAMP servers.

  137. Phamus Jose

    Thanks .. worked perfectly

  138. Thanks it really helped me!

  139. Thank You Barry for sharing this awesome article, for a long time I was using shared hosting and this article helped me when there’s any problem while installing WordPress, so far, I have now moved to managed WordPress and using their console to install everything, but still I am hosting some blogs on shared hosting get help from this post written by you.

  140. Thanks a lot! this works for my mac localhost

  141. Barry, good job done!

  142. Thanks! It worked for me Barry

  143. Great. Helped me a lot. It just works.

  144. brian nanda

    THANKS.. wonderful solution!

  145. great! the quickest help with config I’ve ever had 😀 thanks a lot!

  146. Thank you it works

  147. Thanks!! It works!

  148. Awesome issues here. I am very glad to see your post.
    Thank you so much and I am having a look ahead to contact you.
    Will you kindly drop me a e-mail?

  149. This is what i am looking for. very helpful.

  150. Thanks it works.

  151. Thanks for informatios, its very helping.

  152. An intriguing discussion is worth comment. I do believe that you should publish more
    about this issue, it might not be a taboo matter but generally
    folks don’t speak about such issues. To the next! Kind regards!!

  153. Thanks for sharing this blog. I am curious about how can I install plugins. Now I can try with your support so that may be I do not get any error while adding.


    Amazing! Thank’s!

  155. Finally find a working method to fix plugins install issue! Thanks.

  156. Hello! I just wanted to ask you where exactly should I place the recommended code. I’m a complete beginner in this and when I simply added it at the end of the file, it reported a mistake.

    Thanks in advance!

  157. Bro you saved me its works like superman and batman too
    thanks even it’s from 2013 its saved us

  158. Funcionó perfectamente GRACIAS! Thank you 🙂

  159. You’ve been great to me. Thank you!

  160. I’m so in love with this. You did a great job!!

  161. Bob Hairstyles

    May I request that you elaborate on that? Your posts have been extremely helpful to me. Thank you!

  162. Lynna Rosenholm

    there are so many careers to choose from but the unemployment rate these days have risen::

  163. Master, I have a request from you: How can I remove or change the permanent link of this plugin in Page Tag Cloud? Please help me.

  164. Foreign Exchange is the mondial business market where international currencies are free of charge traded. Traders engage to buy a certain quantity of one currency with a certain quantity of another one. Nowadays, Foreign Exchange Market Trading is done directly. Forex trading market can be considered as a single market. It is the world’s biggest financial market. Trillions of dollars are traded daily in this business market. Everyperson is invited. It is in truth international market. It is a varied market with forex centres all around the planet Earth. Forex not alike major stock exchanges works 24 hours daily except on weekends. It is completely based on the info tech platform. The forex market is a great opportinuty for you. Are you ready?

  165. do cbd gummies make you poop

    is delta 8 legal in new york state

  166. It is my belief that mesothelioma is most lethal cancer. It contains unusual characteristics. The more I look at it the greater I am persuaded it does not react like a real solid cells cancer. In case mesothelioma can be a rogue viral infection, therefore there is the prospects for developing a vaccine as well as offering vaccination for asbestos uncovered people who are vulnerable to high risk with developing future asbestos related malignancies. Thanks for expressing your ideas for this important health issue.

  167. One other issue is that if you are in a problem where you will not have a co-signer then you may want to try to exhaust all of your educational funding options. You will discover many awards and other free college funding that will offer you funding to assist with school expenses. Thank you for the post.

  168. Beauty Fashion

    Thanks for your write-up. I would like to say this that the first thing you will need to complete is check if you really need credit improvement. To do that you will have to get your hands on a copy of your credit file. That should never be difficult, considering that the government makes it necessary that you are allowed to obtain one absolutely free copy of your own credit report per year. You just have to inquire the right people today. You can either check out the website with the Federal Trade Commission or even contact one of the major credit agencies immediately.

Leave a Reply

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