Can't install Wordpress themes - FTP Error

August 13, 2014 13.1k views

Hey all,

Newbie to development here.

I'm getting this error when I try to install a theme from Wordpress: "Failed to connect to FTP Server".

It's asking me for my hostname, username, and password which I put in (checked to see if they are correct from Transmit 2 and SSH).

What I find weird is that Transmit connects to SFTP through port 22 (which I thought was dedicated to SSH) and when I try to connect through port 21 (which Wordpress tries to do) it fails.

If it helps -- I installed Wordpress using the Ubuntu 14.04 guide. Another thing: I think I installed my original droplet with the LAMP stack, but then installed it again with the LAMP Stack Guide for Ubuntu 14.04, don't know if that would cause these sorts of problems.

Any help would be much appreciated! Thanks in advance.

3 Answers

You don't need FTP for installing a theme.
Open wp-config.php file into Wordpress root installation folder and add

define('FS_METHOD', 'direct');

It should works.

  • So I got it working by doing this and then ran this:
    chown -R www-data:www-data /var/www
    find /var/www/ -type d -exec chmod 755 {} \;
    find /var/www/ -type f -exec chmod 644 {} \;

    Is this secure?

  • That's fine.

  • Hello,

    I also added this define('FSMETHOD', 'direct'); in wp-config.php file:
    define('FSMETHOD', 'direct');

    Then I did this in terminal:
    chown -R www-data:www-data /var/www
    find /var/www/ -type d -exec chmod 755 {} \;
    find /var/www/ -type f -exec chmod 644 {} \;

    After these two steps:
    I deleted define('FS_METHOD', 'direct'); in wp-config.php file and I was still able to update one plugin and three themes in WordPress.

    Is it okay and secure that I deleted define('FSMETHOD', 'direct'); in wp-config.php file or is it better to have define('FSMETHOD', 'direct'); in wp-config.php file for future updates?

    • Can you help me with this? I made this steps in my Ubuntu server, but now I can't access wp-admin.php in my browser. It shows to me a "403 - Forbidden" error. What did I wrong?

      I am a newbie, and am learning.

  • Had the same question and this worked for me ..

    Thanks !

I faced the same problem. Apparently Ubuntu only allows SFTP. Have you got your SSH public and private keys set up? If not, try this link, solved it for me

by Justin Ellingwood
WordPress is the most popular content management system (CMS) on the web currently. While WordPress can be a great way to manage you content, there are some very insecure configurations that are given throughout the internet. This article will cover how to set up secure updates and installations using SSH keys instead of FTP, which is an inherently insecure protocol.
Have another answer? Share your knowledge.