When I try to upload a theme in my Wordpress website I need to fill in FTP credentials.

I've installed vsftpd on my Ubuntu 18.04 server. When I connect with the credentials in my FTP client (ex. Cyberduck on mac) I see the following:

enter image description here

The problem is when I try this in Wordpress I get the error FTP + Unable to locate WordPress content directory (wp-content).. What could be the problem here?

  • You're managing this server on your own, right? Instead of giving WordPress the FTP credentials, I would rather make sure the user PHP/WordPress is running as has access to these files. Usually you can do this by doing sudo chown -R www-data:www-data .
    – kero
    Commented Jun 24, 2019 at 8:24

2 Answers 2

  • All files should be owned by the actual user's account, not the user account used for the httpd process.
  • Group ownership is irrelevant unless there are specific group requirements for the web-server process permissions checking. This is not usually the case.
  • All directories should be 755 or 750.
  • All files should be 644 or 640. Exception: wp-config.php should be 440 or 400 to prevent other users on the server from reading it.
  • No directories should ever be given 777, even upload directories. Since the PHP process is running as the owner of the files, it gets the owners permissions and - - can write to even a 755 directory.

You can use

chown www-data:www-data  -R * 
find . -type d -exec chmod 755 {} \;  
find . -type f -exec chmod 644 {} \;

you can also trying the following

add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
define('WP_TEMP_DIR', ABSPATH . 'wp-content/tmp');

The tmp folder wasn't having the permission and that caused the website plugins from updating.


You might be on one of those servers which move the /wp-content/ directory one level up for security purposes.

Did you ask the hosting provider for these details? Where are you hosted?

UPDATE: Check your wp-config.php file for these details:

define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/../wp-content' );
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );
  • wp-content is the directory that should be publicly accessible as it contains static files. I don’t think any hosting company would move it out of document root... Commented Jun 24, 2019 at 9:04
  • Lots of companies move this folder outside the root. It's bad practice, but this is how they mitigate security threats.
    – Ciprian
    Commented Jun 24, 2019 at 9:35
  • are you talking about wp-content directory? If so, then it's really hard to believe... If you move this folder outside of documentroot, media uploads (images and so on) won't work at all... So such site will be useless... And it has no security advantage. There are some files/directories that can be moved up a level (wp-config.php for example), but definitely not wp-content. Commented Jun 24, 2019 at 9:44
  • I am talking about the /wp-content/ directory, yes. And they use server-side rewrites for this directory. I had the same issue myself with a client before.
    – Ciprian
    Commented Jun 24, 2019 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.