504 Gateway error for one user

504 Gateway error for one admin user when logging in on webpage. Webdav also fails via windows explorer.

All other users can login.
Have reset password for user
Have reset quota for user (unlimited)
Currently running “sudo docker exec -ti --user www-data nextcloud-app /var/www/html/occ files:scan --all” waiting for it to complete

Nextcloud version _18.0.4
Operating system and version _debian 10 (buster)
I run a docker yml file which pulls the “latest”

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Log in via web and use that one user and it times out. All other users can log in.

The output of your Nextcloud log in Admin > Logging:

[core] Warning: Login failed: 'Jesse' (Remote IP: '')

PROPFIND /remote.php/dav/files/jesse/
from at 2022-04-13T22:33:07+00:00

Here is some more info further to the problem. if I run “sudo docker exec -ti --user www-data nextcloud-app /var/www/html/ occ files:scan user” I get the following errors:

Exception during scan: “files/e4a0ffaf5e34d8c13b4d1463b330e805” is locked
#0 /var/www/html/lib/private/Files/Storage/Common.php(747): OC\Lock\DBLockingProvider->acquireLock(‘files/e4a0ffaf5…’, 2)
#1 /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php(593): OC\Files\Storage\Common->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#2 /var/www/html/lib/private/Files/Cache/Scanner.php(332): OC\Files\Storage\Wrapper\Wrapper->acquireLock(‘scanner::’, 2, Object(OC\Lock\DBLockingProvider))
#3 /var/www/html/lib/private/Files/Utils/Scanner.php(261): OC\Files\Cache\Scanner->scan(’’, true, 3)
#4 /var/www/html/apps/files/lib/Command/Scan.php(151): OC\Files\Utils\Scanner->scan(’/jesse’, true, NULL)
#5 /var/www/html/apps/files/lib/Command/Scan.php(207): OCA\Files\Command\Scan->scanFiles(‘jesse’, ‘/jesse’, Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#6 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/html/core/Command/Base.php(168): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /var/www/html/3rdparty/symfony/console/Application.php(915): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/3rdparty/symfony/console/Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/lib/private/Console/Application.php(214): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/console.php(99): OC\Console\Application->run()
#13 /var/www/html/occ(11): require_once(’/var/www/html/c…’)
#14 {main}

Due to the locked file I thought I would run the database delete locked files. Here’s the steps I took:

  1. docker exec --user www-data nextcloud-app php occ maintanence:mode --on
  2. docker exec -it nextcloud-mariadb /bin/bash
  3. mysql -u root -p
  4. Show Databases;
  5. Use nextcloud;
  6. show tables;
  7. select * from oc_file_locks;
  8. DELETE FROM oc_file_locks WHERE 1;
    9.select * from oc_file_locks; (confirm no files with a “1” in it)
  9. docker exec --user www-data nextcloud-app php occ maintenance:mode --off
  10. sudo docker exec -ti --user www-data nextcloud-app /var/www/html/ occ files:scan user

Still get the same errors. Ultimately, user can’t login.

Still trying to figure this out. I have abandoned the idea of getting help on how to recover a user and for those who have the same problem here is what else I’ve tried so far.

  1. Created a new user
  2. Transferred the files/ownership over to the new user. In terminal: sudo docker exec -ti --user www-data nextcloud-app /var/www/html/occ files:transfer-ownership <old_*user> <new_*user>
  3. wait
  4. Ran OCC file scan to update the database: sudo docker exec -ti --user www-data nextcloud-app /var/www/html/occ files:scan --all
  5. Removed the old user: sudo docker exec -ti --user www-data nextcloud-app php occ user:delete
  6. Logged in with the new user and had the same gateway error
  7. Checked the user files and noticed 2 directories one called “money$$$$$” and another called “My *Important Files”. I renamed the files to “money” & “My Important files”
  8. Re ran the occ filescan from above
  9. Logged back in as the new user & success!!!
  10. Need to add the old user back in and transfer files back into old user
  11. Recreated old user and tried to log in. Had same gateway timeout error as before. I also noticed that it repopulated the del users picture in the recreated profile.
  12. Once again removed the old user from both the web config & the occ user:delete
  13. I log into the mysql and run “select * FROM oc_users;” I confirm the deleted user no longer there
  14. Do a search in the nextcloud folder & notice in /nextcloud/app/data/apppdata_oc5xaatrriz7/avatar & …/appdata…/identityproof/ the old user is in there. Delete both of those folders. Recreated the old user and still failed
  15. Tried creating same user with a different password…still failed
  16. I cant create a new user with the old users name. I have created a new user with a unique name and will let the user now their new login name. I have no idea what’s wrong as the user is not in the mysql table so it must have that username locked somewhere in one of the other files.

I hope it helps save someone else some time. Maybe it’s a bug in nextcloud?


dumb question, but have you tried to cache-cleaning the user’s computer/browser ?

I have the same problem here. Did you already find a solution?

I did. Clear cookies. Incognito mode. Other browser. Other device. On another computer (tried 3 devices in total), another account works but mine does not. Impersonating works, but logging in with my account does not. Logging in with another account is working.

No, I could not find an answer here. I’m surprised none of the admins could/would help. A little discouraging. Eventually I just created a new user instead of “user” it’s now “user1”

It’s a workaround. Hopefully this will bring some attention to this problem though.

I have the same error for one admin user. To be a little bit more precise:

  • Everything worked fine till I changed the password for that user after my phone was robbed
  • Even after the password change everything was nice
  • Suddenly the login stopped working for this user. Getting a 504 gateway timed out after approx. 1 Minute
  • Created new admin user with OCC: can login with no problems, all other users (non-admin) can login

These are the things I did until now:

  • Cleaned the oc_bruteforce_attempts table
  • Cleaned the oc_filelocks_table
  • Checked the nextcloud logs (no errors)
  • Searched the forum and the internet
  • Did not try to set the proxy timeout to a higher level beacause it worked before with this settings

My setup:

  • NGINX proxy
  • Nextcloud docker container
  • MariaDB docker container

[SOLVED] in my case…
I could login with my user after using

occ files:scan-app-data

I don’t understand why this helped but perhaps there are some other peolple out there who have the same problem. Seems that 504 -Gateway - error is quite common…