Endless login loop - not able to login with one user only in web browser


Nextcloud version: 21.0.2
Operating system and version: Synology DSM 6.2.4
Apache or nginx version: Apache 2.4.43
PHP version: 7.3.16

The issue:
I cannot login with one user only.

I have four users. 1 administrator and 3 users. Only one of the users (the user which owns most of the data) cannot login. After updating to Nextcloud 21 this user can never login. Previously, the problem occured only randomly. (But it must not be related to the update, as the user was not used in the last months before the update was performed.) Using the mobile app on Android, I can login with this user and browse the files.

Is this the first time you’ve seen this error?
No, but as it was always working after second or third try, I didn’t investigate further.

Steps to replicate it:

  1. Go to …/index.php/login
  2. Enter valid credentials of one user
  3. See login page reloading after approx. 1min. The user is not logged in
  4. Enter valid credentials of a different user
  5. User is logged in immediatly

What I tried so far:

  • Changing password to make sure the correct one is used → yes it is
  • Cleaned up oc_bruteforce_attempts table → no effect
  • Login with other existing users, login with newly created user → all good
  • Login with specific user using Andorid mobile application - > works

Nextcloud log:

[core] Warning: Controller OC\Core\Controller\LoginController::tryLogin executed 1111 queries.
POST /index.php/login

[core] Debug: Controller OC\Core\Controller\LoginController::tryLogin created 1107 QueryBuilder objects, please check if they are created inside a loop by accident.
POST /index.php/login


$CONFIG = array (
  'trusted_domains' =>.
  array (
    0 => '...',
    1 => '...',
    2 => '...',
    3 => '...',
  'datadirectory' => '/volume1/nextcloud',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => '...',
  'dbname' => '...',
  'dbhost' => '...',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '...',
  'dbpassword' => '...',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_from_address' => '...',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '...',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '...',
  'mail_smtpport' => '587',
  'mail_smtpname' => '...',
  'mail_smtppassword' => '...',
  'mail_smtpsecure' => 'tls',
  'maintenance' => false,
  'updater.secret' => '...',
  'theme' => '',
  'loglevel' => 2,
  'debug' => 'false',
  'defaultapp' => 'dashboard',
  'app_install_overwrite' =>.
  array (
    0 => 'calendar',

Apache log:

[proxy_fcgi:error] [pid 17064:tid 547792875936] (70007) The timeout specified has expired: [client …] AH01075: Error dispatching request to : (polling)

Highly appreciate every feedback!

I solved it.

In fact, the login page reloading was a 504 error returned by the web server. This was caused by a timeout setting of 60s. After a lot of searching, I found the following answer which helped to solve my problem: Nextcloud installation: Error while trying to create admin user on Synology Running DSM 6.2.3 - #4 by matkinson

As I am using Apache 2.4 I had to add /usr/local/etc/apache24/sites-enabled/user.conf with the content below:

TimeOut 300
ProxyTimeout 300

I’m still confused why logging in with this user now takes nearly 2min, while other users are logged in after 1-2 seconds. Maybe I’ll investigate another time.

I would suggest to create a new thread with that issue, you have marked this one as solved, which is correct, but that means nobody will look into your remaining problem… dont forget to add logs…