Troubleshooting: Nextcloud Login Hangs (Requires Manual Refresh to Access Dashboard)
📌 Problem Description
After entering valid user credentials on the Nextcloud login page, the loading spinner spins indefinitely. The user is not automatically redirected to the dashboard. However, if the user manually refreshes the browser page, the dashboard loads instantly, confirming that the login session was successfully created in the background.
🔍 Root Cause
This issue typically occurs when Nextcloud is deployed behind a reverse proxy (e.g., Nginx Proxy Manager, Cloudflare Tunnels, Traefik, Apache).
- Protocol Mismatch: Nextcloud fails to recognize that the client is connecting securely via
https://and defaults to generating internal redirect URLs using insecurehttp://. - Mixed Content Block: Modern web browsers block this redirect because switching from HTTPS to HTTP violates security policies.
- Throttling: Nextcloud treats the unrecognized proxy connections as a potential brute-force attack, throttling the response speed.
🛠️ Solution
To resolve this, Nextcloud must be forced to use HTTPS for all internal links, and the reverse proxy's network address must be whitelisted.
Step 1: Force HTTPS Protocol Overwrites
Open your Nextcloud installation directory and edit the main configuration file located at config/config.php. Add or update the following configuration strings:
'overwrite.cli.url' => 'https://your-nextcloud-domain.com',
'overwriteprotocol' => 'https',
Note: Replace https://your-nextcloud-domain.com with your actual external domain name. The overwriteprotocol line is usually missing by default and must be explicitly added.
Step 2: Configure Trusted Proxies
In the same config/config.php file, locate or create the trusted_proxies array. Add the internal IP address of your reverse proxy to this list.
'trusted_proxies' => array(
0 => '127.0.0.1',
1 => '172.18.0.1', // Example: Internal Docker network gateway
2 => '192.168.1.50', // Example: Standalone reverse proxy LAN IP
),
How to find your Proxy IP:
- Via Nextcloud Logs: Check
data/nextcloud.logimmediately after a login attempt. Look for the value assigned to"remoteAddr". - Via Docker: Run
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <proxy-container-name>.
Step 3: Apply & Verify
- Save the changes to
config/config.php. - Clear your web browser cache or open a private/incognito window.
- Log out of Nextcloud and log back in. The redirect from the login panel to the dashboard should now happen instantly.