Login loop - need help debugging

Nextcloud version (eg, 12.0.2): 16.0.3 (but attempted to load 16.0.0, and 15.0.0 under a different folder, with similar results)
Operating system and version (eg, Ubuntu 17.04): Fedora Core 30
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.39
PHP version (eg, 7.1): 7.3.7

The issue you are facing:
Attempting to login results in being redirected to the login page.

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

Steps to replicate it:

  1. Browse
  2. Type in any username/password (doesn’t even have to be a registered user)
  3. redirected to host/nextcloud/index.php/login?redirect_url=/nextcloud/index.php/apps/files/ via status code 303

The output of your Nextcloud log in Admin > Logging:

Nothing present except failed logins from the nextcloud app, interestingly nothing from my attempts from logins from users that don't even exist.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'fake thing',
  'trusted_domains' => 
  array (
    0 => 'longwing.us',
    1 => '192.168.2.3',
  ),
  'datadirectory' => '/mymedia/CloudStore',
  'version' => '16.0.3.0',
  'dbtype' => 'mysql',
  'dbhost' => 'localhost',
  'dbname' => 'fakedatabase',
  'dbuser' => 'fakeusername',
  'dbpassword' => 'fakepassword',
  'dbtableprefix' => 'oc_',
  'installed' => true,
  'default_language' => 'en',
  'force_language' => 'en',
  'default_locale' => 'en_US',
  'force_locale' => 'en_US',
  'defaultapp' => 'files',
  'knowledgebaseenabled' => true,
  'allow_user_to_change_display_name' => true,
  'remember_login_cookie_lifetime' => 1296000,
  'session_lifetime' => 86400,
  'session_keepalive' => true,
  'token_auth_enforced' => false,
  'auth.bruteforce.protection.enabled' => true,
  'skeletondirectory' => '/path/to/nextcloud/core/skeleton',
  'lost_password_link' => 'https://example.org/link/to/password/reset',
  'mail_domain' => 'example.com',
  'mail_from_address' => 'nextcloud',
  'mail_smtpdebug' => false,
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => '127.0.0.1',
  'mail_smtpport' => 25,
  'mail_smtptimeout' => 10,
  'mail_smtpsecure' => '',
  'mail_smtpauth' => false,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'mail_template_class' => '\\OC\\Mail\\EMailTemplate',
  'mail_send_plaintext_only' => false,
  'mail_smtpstreamoptions' => 
  array (
  ),
  'mail_sendmailmode' => 'smtp',
  'overwritehost' => '',
  'overwriteprotocol' => '',
  'overwritewebroot' => '',
  'overwritecondaddr' => '',
  'overwrite.cli.url' => '',
  'htaccess.RewriteBase' => '/',
  'htaccess.IgnoreFrontController' => false,
  'proxy' => '',
  'proxyuserpwd' => '',
  'trashbin_retention_obligation' => 'auto',
  'versions_retention_obligation' => 'auto',
  'appcodechecker' => true,
  'updatechecker' => true,
  'updater.server.url' => 'https://updates.nextcloud.com/updater_server/',
  'updater.release.channel' => 'stable',
  'has_internet_connection' => true,
  'connectivity_check_domains' => 
  array (
    0 => 'www.nextcloud.com',
    1 => 'www.startpage.com',
    2 => 'www.eff.org',
    3 => 'www.edri.org',
  ),
  'check_for_working_wellknown_setup' => true,
  'check_for_working_htaccess' => true,
  'check_data_directory_permissions' => true,
  'config_is_read_only' => false,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud.log',
  'logfilemode' => 416,
  'loglevel' => 2,
  'syslog_tag' => 'Nextcloud',
  'log.condition' => 
  array (
    'shared_secret' => 'fake secret',
    'users' => 
    array (
      0 => 'sample-user',
    ),
    'apps' => 
    array (
      0 => 'files',
    ),
  ),
  'logdateformat' => 'F d, Y H:i:s',
  'logtimezone' => 'Europe/Berlin',
  'log_query' => false,
  'log_rotate_size' => 104857600,
  'customclient_desktop' => 'https://nextcloud.com/install/#install-clients',
  'customclient_android' => 'https://play.google.com/store/apps/details?id=com.nextcloud.client',
  'customclient_ios' => 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8',
  'customclient_ios_appid' => '1125420102',
  'appstoreenabled' => true,
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/nextcloud/apps',
      'url' => '/apps',
      'writable' => true,
    ),
  ),
  'enable_previews' => true,
  'preview_max_x' => 4096,
  'preview_max_y' => 4096,
  'preview_max_filesize_image' => 50,
  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'preview_office_cl_parameters' => ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to png --outdir ',
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\HEIC',
    4 => 'OC\\Preview\\BMP',
    5 => 'OC\\Preview\\XBitmap',
    6 => 'OC\\Preview\\MP3',
    7 => 'OC\\Preview\\TXT',
    8 => 'OC\\Preview\\MarkDown',
  ),
  'ldapUserCleanupInterval' => 51,
  'sort_groups_by_name' => false,
  'comments.managerFactory' => '\\OC\\Comments\\ManagerFactory',
  'systemtags.managerFactory' => '\\OC\\SystemTag\\ManagerFactory',
  'maintenance' => false,
  'openssl' => 
  array (
    'config' => '/absolute/location/of/openssl.cnf',
  ),
  'debug' => true,
  'theme' => '',
);

The output of your Apache/nginx/system log in /var/log/____:

174.204.31.16 - - [30/Jul/2019:08:52:28 -0400] "POST /nextcloud/index.php/login?redirect_url=/nextcloud/index.php/apps/files/ HTTP/1.1" 303 -
174.204.31.16 - - [30/Jul/2019:08:52:29 -0400] "GET /nextcloud/index.php/apps/files/ HTTP/1.1" 303 -
174.204.31.16 - - [30/Jul/2019:08:52:29 -0400] "GET /nextcloud/index.php/login?redirect_url=/nextcloud/index.php/apps/files/ HTTP/1.1" 200 14711
174.204.31.16 - - [30/Jul/2019:08:52:31 -0400] "GET /nextcloud/cron.php HTTP/1.1" 200 20


(nothing shows up in error log)

Apologies, I should have posted this along with the original report, however yes I have tried different browsers, different devices, clearing cache, even a fresh install of one of my work stations (converting away from windows at the time so the timing worked out).

I should add here as well that attempts to login through the app has a similar response, returns to login screen.

Password reset, used copy/paste to put the same password in, still failed.

Update: I can access through rclone (using the reset password), however the apps/webpage still fail to login

Did you set up these options in your configuration by purpose? Normally you are not supposed to set everything and only those that are important for you.

From your apache log, you have a few redirections, this POST is redirected:

"POST /nextcloud/index.php/login?redirect_url=/nextcloud/index.php/apps/files/ HTTP/1.1"  303 -

The same GET is not redirected:

"GET /nextcloud/index.php/login?redirect_url=/nextcloud/index.php/apps/files/ HTTP/1.1" 200

Perhaps some of your rewrite stuff got a bit messed up, perhaps there are some things changed in the .htaccess that you don’t allow to change via apache-config.

Is this something new, or after a update or something?

During debugging I removed the configuration, but realized afterwards it was not in my backups, that config was my attempt to re-construct it.

This has cropped up sometime within the last couple months, but I don’t know what triggered it.

I stripped out all of my rewrites and reloaded but it still happened, I am starting to wonder if I am loading a different configuration file than I think.

Good news and bad news, I restarted my instance from zero, and now everything works.

Bad news: I have no idea what caused or fixed my issue. Near as I can tell there was an update that broke my instance, and another update to my packages that fixed everything.