Page reload loop at login (can't login) - nothing in logs

Nextcloud version:
Operating system and version: Ubuntu 21.10 (GNU/Linux 5.13.0-37-generic x86_64)
Apache or nginx version: 2.4.48
PHP version: 8.0.8
Is this the first time you’ve seen this error? Yes


After a fresh install, the login page just loops (reloads the same page), so I can’t login.
If I could just get some help to make the logs show something (anything) useful, I’d be stoked.

Steps to Replicate

  1. Visit any nextcloud web page (except version.php, status.php and robots.txt)
  2. It redirects to the /login page
  3. Enter the username & password of either an admin or a non-admin user
  4. Click “Login” button
  5. The page refreshes and you’re back at the same /login page


The installation is freshly re-installed after an initial install that worked fine for a while until I botched it up for some reason, so I reinstalled it by deleting and recreating the MariaDB database and emptying the /var/www/nextcloud folder and reinstalling. So I’m pretty sure it’s a clean install. I have not been able to successfully login yet.

What I’ve tried:

  • Creating a non-admin user via occ and logging in with that
  • Flushing browser cache
  • Private browsing mode
  • Using a different browser (Firefox & Chrome)
  • Login with a device
  • Restarting Apache & MariaDB
  • sudo chown -R www-data:www-data /var/www
  • occ check
  • occ maintenance:repair
  • occ maintenance:update:htaccess
  • occ maintenance:mimetype:update-js
  • occ maintenance:mimetype:update-db
  • occ maintenance:theme:update
  • occ update:check
  • Disabling as many apps as possible via occ app:disable
  • Searching the net for anything interesting in the logs

Troubleshooting Info

  • The weirdest bit is that although I’ve turned all (NextCloud, Apache and PHP) logging up the the max and the logs are still way too quiet. Although I can write to php_errors.log via a throw command in a standalone PHP script, the php_errors.log file is suspiciously empty.
  • I always call occ as the www-data user, as per the doco
  • Browser console reports that the following modules are deprecated, stating “please ship your own, this will be removed in Nextcloud 20”: global jQuery, global $, Backbone, Handlebars
  • Browser console also reports:
    • No OC found
    • Proxying an event bus of version 2.1.1 with 1.3.0
  • /version.php - times out
  • /robots.txt - works
  • /status.php - works, returning: {"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"","versionstring":"23.0.3","edition":"","productname":"Nextcloud","extendedSupport":false}
  • The server is only accessible locally on my LAN for now (will harden later)
  • I have a fairly strict Adblocker/VPN/firewall for the internet connection, but nothings blocked that I can see
  • I installed a LetsEncrypt SSL using certbot
  • I set up a cron job to call cron.php
  • At one point I had a CSP error but this is now gone: “Content Security Policy: The page’s settings blocked the loading of a resource at …/favicon.ico” (default-src)


…contains nothing but the result of cron job

{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Run OCA\\Files\\BackgroundJob\\CleanupFileLocks job with ID 28","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Finished OCA\\Files\\BackgroundJob\\CleanupFileLocks job with ID 28 in 0 seconds","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Run OC\\Authentication\\Token\\DefaultTokenCleanupJob job with ID 30","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Invalidating session tokens older than 2022-03-28T21:30:02+00:00","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Invalidating remembered session tokens older than 2022-03-14T21:30:02+00:00","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Invalidating session tokens older than 2022-03-28T21:30:02+00:00","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Invalidating remembered session tokens older than 2022-03-14T21:30:02+00:00","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Finished OC\\Authentication\\Token\\DefaultTokenCleanupJob job with ID 30 in 0 seconds","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Run OC\\Log\\Rotate job with ID 31","userAgent":"--","version":""}
{"reqId":"xxx","level":0,"time":"2022-03-29T21:30:02+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Finished OC\\Log\\Rotate job with ID 31 in 0 seconds","userAgent":"--","version":""}


$CONFIG = array (
  'instanceid' => 'xxx',
  'overwrite.cli.url' => 'https://xxx.yy/',
  'htaccess.RewriteBase' => '/',
  'trusted_domains' =>
  array (
    0 => 'xxx.yy'
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'xxx',
  'dbhost' => 'xxx',
  'dbport' => '',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'maintenance' => false,
  'log_type' => 'file',
  'logfile' => '/var/www/nextcloud/nextcloud.log',
  'loglevel' => 0,
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'dbtableprefix' => 'xxx',
  'installed' => true,
  'maintenance_window_start' => 3,
  'debug' => true,
  'data-fingerprint' => 'xxx',


[Wed Mar 30 00:00:02.558457 2022] [mpm_prefork:notice] [pid 140033] AH00163: Apache/2.4.48 (Ubuntu) OpenSSL/1.1.1l configured -- resuming normal operations
[Wed Mar 30 00:00:02.558515 2022] [core:notice] [pid 140033] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 30 05:54:25.357784 2022] [mpm_prefork:notice] [pid 140033] AH00170: caught SIGWINCH, shutting down gracefully
[Wed Mar 30 05:54:25.640895 2022] [mpm_prefork:notice] [pid 143024] AH00163: Apache/2.4.48 (Ubuntu) OpenSSL/1.1.1l configured -- resuming normal operations
[Wed Mar 30 05:54:25.641018 2022] [core:notice] [pid 143024] AH00094: Command line: '/usr/sbin/apache2'

Config for the only enabled Apache site

<VirtualHost *:443>
  DocumentRoot /var/www/nextcloud/
  ServerName  xxx.yy

  <Directory /var/www/nextcloud/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/xxx.yy/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxx.yy/privkey.pem


your trust domain is empty or erased for privacy ??

You cant check those production conf files they might help you: Nextcloud

the trust domain is just xxx.yy for privacy

Hi @bubba241, have you tried to clear the cache and cookies of your web browser?

Yep. Point two of “what I’ve tried” above.

It’s a tricky one, eh?

I just added the vhosts config

@bubba241 sorry, I misread your 1st message. The redirection between HTTP to HTTPS is ok?

@Mageunic yep it redirects fine from HTTP to HTTPS

Why do you think the logs are showing nothing?

Finally solved this by running occ:integrity check-core and copying the reported files back from the install zip.

1 Like

I have similar symptoms:

  1. Cannot login. Login page loops back and asks for credentials when I enter them. I can see the traffic between the browser and Nextcloud in the webserver logs (POST to send the credentials and redirect to reload the page).
  2. Nothing shows up in the log for the login failures.
  3. The client applications on my devices continue to sync with Nextcloud.
  4. I can access “php occ”, but nothing I do helps. I tried all of the fixes here.

Any help is greatly appreciated. My config file is:

<?php $CONFIG = array ( 'passwordsalt' => 'xxxx', 'secret' => 'xxxx', 'datadirectory' => 'xxxx', 'dbtype' => 'mysql', 'version' => '', 'overwriteprotocol' => 'https', 'overwrite.cli.url' => 'xxxx', 'dbname' => 'nextcloud', 'dbhost' => 'xxxx', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'xxxx', 'dbpassword' => 'xxxx', 'installed' => true, 'instanceid' => 'xxxx', 'trusted_proxies' => array ( 0 => 'xxxx', 1 => 'xxxx', 2 => 'xxxx', 3 => 'xxxx', ), '‘overwriteprotocol’' => '‘https’', 'trusted_domains' => array ( 0 => 'xxxx', 1 => 'xxxx', 2 => 'xxxx', 3 => ' xxxx', ), 'default_phone_region' => 'US', 'loglevel' => '2', 'logtimezone' => 'xxxx', 'maintenance' => false, 'mail_smtpmode' => 'smtp', 'mail_smtpauth' => 1, 'mail_sendmailmode' => 'smtp', 'mail_smtpauthtype' => 'LOGIN', 'mail_smtphost' => 'smtp.xxxx', 'mail_smtpport' => '587', 'mail_from_address' => 'xxxx', 'mail_domain' => 'xxxx', 'mail_smtpsecure' => 'tls', 'mail_smtpname' => 'xxxx', 'mail_smtppassword' => 'xxxx', 'data-fingerprint' => 'xxxx', );

I found the answer to my problem. The directory at /var/cache/php needed to be owned by the webserver user. PHP session caches are stored there.