3

I followed Failed to connect to FTP Server 127.0.0.1/:21

And was able to solve that problem. But now when I try to upload the theme then I get username and password failure.

I have added following lines in wp-config.php

define( 'FS_METHOD', 'ftpext' );
define( 'FTP_BASE', '/var/www/wordpress/' );
define( 'FTP_CONTENT_DIR', '/var/www/wordpress/wp-content/' );
define( 'FTP_PLUGIN_DIR ', '/var/www/wordpress/wp-content/plugins/' );
define( 'FTP_USER', 'username' );
define( 'FTP_PASS', 'password' );
define( 'FTP_HOST', 'localhost' );
define( 'FTP_SSL', false );

How I can resolve this problem?enter image description here

UPDATE:

I tried this link and removed all values for ftp which are in wp-config.php But still same error.

5
  • So you want to bypass from this step? Mar 24, 2014 at 12:01
  • No, I want to use the authentication but it is saying wrong authentication Mar 24, 2014 at 12:25
  • Have you tried sFTP?
    – s_ha_dum
    Mar 24, 2014 at 13:49
  • Can you upload the theme via FTP then just activate it in WP?
    – Aaron
    Mar 24, 2014 at 14:36
  • The username and password you put in are correct right? you haven't just copypasted without modification?
    – Tom J Nowell
    Mar 24, 2014 at 14:50

3 Answers 3

3

if you do not want to (or you cannot) change permissions on wp-content so your web server has write permissions, then add this to your wp-config.php file:

define('FS_METHOD', 'direct');
4
  • 1
    Please add an explanation to your answer: why could that solve the problem?
    – fuxia
    Apr 4, 2016 at 7:13
  • Don't ask FTP Hostname,username,pass. this code Direct Access.
    – Nik
    Apr 4, 2016 at 7:17
  • Please edit your answer. Explain what happens.
    – fuxia
    Apr 4, 2016 at 7:20
  • +1 Exactly what was needed. I believe this should be more secure than ftp since wp already has group privileges to edit /var/www/html (as with when you upload an image), and thus should apply to plugins and exentions (which ask for ftp by default).
    – Lone Wolf
    Jan 27, 2020 at 18:25
1

Back up the config file before making a change;

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.back

and then edit vsftpd.conf (with vi or nano)

nano /etc/vsftpd.conf

Then make the following change

pam_service_name=ftp

Save your change and restart the ftp server (if you use nano hit CTRL+O & enter to save then CTRL+X to exit)

sudo service vsftpd restart
-1

NO, this is only because of the owner/permission of your folder where wordpress files are present. Please check the folder permission, if that is 0755 then replace it with 0777 by using chmod 777 -R FOLDERNAME and try to upload, After this if will get again same issue change the folder owner by using chown www-data FOLDERNAME

For example in your case the folder name is wordpress then use the following commands for changing permisssion/owner

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

I believe this will work for you.

Also you can define FS_METHOD as direct in wp-config.php so you will not get FTP detials at the time of installation of Theme/Plugin.

define('FS_METHOD', 'direct);

Thanks

1
  • nothing except maybe the upload directory should have a 777 permission Jul 8, 2016 at 7:44

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.