Android app error: "Strict mode, no HTTP connection allowed!"

Nextcloud version (eg, 20.0.5): 22.2.0.2
Operating system and version (eg, Ubuntu 20.04): Docker, Ubuntu 20 on WSL
Apache or nginx version (eg, Apache 2.4.25): Apache
PHP version (eg, 7.4): 7.4

The issue you are facing:
Attempting to login with the android mobile app returns error “Strict mode, no HTTP connection allowed!” By both email/pass and Google SSO. I am able to login via web UI and webdav on the same device.

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

Steps to replicate it:

  1. Fresh install Nextcloud server
  2. Fresh install android app
  3. Log in

The output of your Nextcloud log in Admin > Logging:
No server log errors

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => '*',
  'passwordsalt' => '*',
  'secret' => '*',
  'trusted_domains' => 
  array (
	3 => '*',
	0 => 'localhost',
	1 => '192.168.*.*',
	2 => '172.16.0.0/12',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '22.2.0.2',
  'overwrite.cli.url' => 'http://localhost:8080',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'VzLP6UGH6fqJ2',
  'installed' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
);

as first hint - you should never post you passwords please remove the passwords from you post and change all exposed passwords!

It looks you have HSTS header configured which enforce https but your instance is running on http… from the config you show I have no idea how it could happen (BTW: how do you access “localhost:8080” with android app?)

Whoops, missed that password, thanks. No worries, it’s on an internal-only docker network. I’ll change it after this issue is resolved.

It looks you have HSTS header configured

How do you see that? And I did have HSTS configured on my server some time back, but it was removed before I started trying to install nextcloud. Hold on.

Just tried on another android phone, and it’s having the same issue. However, an iPhone is logging in fine on the app. Also, I’m trying to access an SSL address, so I’m not sure why HSTS would be throwing a fit either way.

Just realised QR code login does work, BTW.

(BTW: how do you access “localhost:8080” with android app?)

I’m not, I’m accessing my domain name.

this results in all URI within you instance a build based on http://localhost:8080 which prevents access to the server from clients and brakes TLS and switch to plain http… I’m really surprised you are able to login and do something…

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html?highlight=overwrite%20cli%20url

maybe you want to review you reverse proxy config

Oh ok. Everything has worked so far except the android client login. The docs say it only affects cronjobs and occ, so perhaps android login just happens to overlap with that somehow. Thanks.

Had the same issue recently, I use a reverse proxy and SSL cert.
Setting ‘overwriteprotocol’ => ‘https’, allowed me login with Android client without any errors.

4 Likes

Hello,

Thanks for pointing out the solution.

Yes, adding that line manually in NextCloud configuration file allows me to get rid of that warning and log in via the android app.

For information, I am using NextCloud Snap behind a reverse proxy running Nginx Reverse Proxy Manager.

Thanks.

Does somebody have a solution without overwriting the protocol? That case local http connection won’t work. Why is this so hard to configure?

On iOS, RequestHeader unset Upgrade for Apache Reverse proxy did the trick.

Hi, I’m also interested in the fix to this problem (not the work@round in config file).
I have nextcloud running in docker, behind nginx proxy manager. SSL certificate is there, + hsts enabled.
Why the app is trying to use HTTP? Can it use x-forwarder-host headers instead?

For anyone facing the same issue when running nexcloud in docker and behind the reverse proxy,
you can add these lines to your docker-compose:

      - OVERWRITECLIURL=https://nextcloud.mydomail.com
      - OVERWRITEPROTOCOL=https

this solved the issue for me

2 Likes

This solution solves the access via the mobile app and using the domain.
but I get no local access via ip since I don’t have a certificate. How to solve? have local and remote access?

By using the domain name also for local access. This has been discussed many times here in the forums…

Short version: Your router must support either NAT Reflection / NAT Loopback or local DNS hostname overrides. Host overrides can also be achieved with a separate local DNS server if the router doesn’t support any of these options.

2 Likes

Just the https as overwriteprotocol was not enough. Once I had OVERWRITECLIURL set correctly, the Android app worked.

Thanks, it worked for me too. Nexcloud and Nginix in CasaOS. I can actually now access with the app under android.

1 Like

I faced the same issue when running nextcloud in docker and proxying through cloudflare tunnel. The nextcloud android app shows the exact same error message when I enter “https://my.domain”, but it works fine when i enter “http://my.domain”. No configuration files have been modified, just changing “https” to “http” works fine for me. And the local connections through “http://192.168.x.x” are not affected.

‘overwriteprotocol’ =>‘https’, paste in config.php under ‘overwrite.cli.url’

Thank you…
Its work for me to…
Nextcloud install on Casaos