Mobile login fails (stuck at loading data) but desktop login works

Ever since the new login implementation I can’t login on my mobile anymore. It just gets stuck on the loading data part, and when checking on the desktop it shows a “Login attempt failed” notification.

The scenario is as follows:

  1. Mobile connected to work Wifi (mobile is a Google Pixel 2 XL running Android P with all apps updated)
  2. Laptop connected to work Wifi
  3. Open HA on laptop (login with new authentication successful)
  4. Open HA on mobile using Chrome or Opera (login with new authentication fails)
  5. On laptop the HA shows login failed notitifcation

Both devices connect with the same public IP address to HA. The following is a snapshot of the log-file while the mobile was trying to connect.

2018-09-14 13:28:25 INFO (MainThread) [homeassistant.components.http.view] Serving / to 148.253.185.37 (auth: False)                                                                      
2018-09-14 13:28:25 INFO (MainThread) [homeassistant.components.http.view] Serving /auth/token to 148.253.185.37 (auth: False)                                                            
2018-09-14 13:28:25 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 148.253.185.37                                     
2018-09-14 13:28:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Login attempt failed, m
essage=Login attempt or request with invalid authentication from 148.253.185.37, notification_id=http-login>                                                                              
2018-09-14 13:28:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.httplogin, old_state=None, new_state=<state persistent_
notification.httplogin=notifying; title=Login attempt failed, message=Login attempt or request with invalid authentication from 148.253.185.37 @ 2018-09-14T13:28:25.574717+01:00>>       
2018-09-14 13:28:25 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]>                                                                                       
2018-09-14 13:28:25 INFO (MainThread) [homeassistant.components.http.view] Serving /auth/authorize to 148.253.185.37 (auth: False)                                                        
2018-09-14 13:28:26 INFO (MainThread) [homeassistant.components.http.view] Serving /auth/providers to 148.253.185.37 (auth: False)                                                        
2018-09-14 13:28:26 INFO (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 148.253.185.37 (auth: False)                                                       
2018-09-14 13:28:30 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sun.sun, old_state=<state sun.sun=above_horizon; next_dawn=2018-09-15T05:00:26+
00:00, next_dusk=2018-09-14T18:54:03+00:00, next_midnight=2018-09-14T23:55:52+00:00, next_noon=2018-09-15T11:56:02+00:00, next_rising=2018-09-15T05:34:32+00:00, next_setting=2018-09-14T1
8:19:53+00:00, elevation=40.64, azimuth=190.58, friendly_name=Sun @ 2018-09-14T13:28:07.850186+01:00>, new_state=<state sun.sun=above_horizon; next_dawn=2018-09-15T05:00:26+00:00, next_d
usk=2018-09-14T18:54:03+00:00, next_midnight=2018-09-14T23:55:52+00:00, next_noon=2018-09-15T11:56:02+00:00, next_rising=2018-09-15T05:34:32+00:00, next_setting=2018-09-14T18:19:53+00:00
, elevation=40.63, azimuth=190.7, friendly_name=Sun @ 2018-09-14T13:28:07.850186+01:00>>                                                                                                  
2018-09-14 13:28:36 INFO (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/01730b35ce394495bf1659cb7aa2d528 to 148.253.185.37 (auth: False)                      
2018-09-14 13:28:36 INFO (MainThread) [homeassistant.components.http.view] Serving / to 148.253.185.37 (auth: False)                                                                      
2018-09-14 13:28:36 INFO (MainThread) [homeassistant.components.http.view] Serving /auth/token to 148.253.185.37 (auth: False)                                                            
2018-09-14 13:28:36 INFO (MainThread) [homeassistant.components.http.view] Serving /manifest.json to 148.253.185.37 (auth: False)

Have you setup ip_ban? If so any chance your work IP is banned? (check your ip_bans.yaml and compare with result of www.whatismyip.com when at work

I have disabled ip_ban and there is also no ip_bans.yaml file in my config directory.

I can see from the log file that both laptop and mobile communicate with the same IP address. If it was banned I would have expected the laptop also to fail.

have you tried to uninstall and reinstall the android app? I had that issue a couple months back and reinstall solved it

also try and clear your cache on your phone

I don’t use the android app. I use the web portal using Chrome and/or Opera. Both of them have the same problem.

Just arrived home and did a bit more digging. When I access HA directly (bypassing the Apache proxy) it works on the mobile. If I try again to use the proxy it fails.

This is currently my Apache config:

CustomLog /var/log/apache2/access_203-85_homeassistant.log combined ErrorLog /var/log/apache2/error_203-85_homeassistant.log
    ServerName home.domain.tld
    ServerAlias home

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    #   A self-signed (snakeoil) certificate can be created by installing
    #   the ssl-cert package. See
    #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
    #   If both key and certificate are stored in the same file, only the
    #   SSLCertificateFile directive is needed.
    SSLCertificateFile    /etc/letsencrypt/live/domain.tld/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/domain.tld/privkey.pem

    ProxyPreserveHost On
    ProxyRequests off
    ProxyPass /api/websocket ws://192.168.7.203:8085/api/websocket
    ProxyPassReverse /api/websocket ws://192.168.7.203:8085/api/websocket
    ProxyPass / http://192.168.7.203:8085/
    ProxyPassReverse / http://192.168.7.203:8085/

    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*) ws://192.168.7.203:8085/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*) http://192.168.7.203:8085/$1 [P,L]

I think I resolved it. I was moving between 2 VM’s and the Apache proxy config wasn’t exactly the same. It seemed that the new Apache setup was using mpm_events instead of mpm_prefork. After I changed that the new setup seems to working as expected on the mobile.