iOS icon indicating copy to clipboard operation
iOS copied to clipboard

Unable to re-authenticate after Home Assistant reinstall – app stuck on “Retry now” on iPhone and iPad

Open markussingerforhomeassistant opened this issue 4 months ago • 16 comments

Image

iOS device model, OS version, and app version

Device 1

  • iPhone 17 Pro Max
  • iOS 26.5.2
  • Home Assistant Companion App 2026.7.2, build 2026.2446

Device 2

  • iPad Pro 11-inch, 4th generation
  • iPadOS 26.6
  • Home Assistant Companion App 2026.7.2, build 2026.2446

Home Assistant Core version

Home Assistant Core 2026.7.4 Home Assistant OS 18.2 Supervisor 2026.07.5

Describe the bug

Home Assistant was completely reinstalled on the same Raspberry Pi.

Both the iPhone and iPad Companion Apps were previously connected to the old Home Assistant installation. After the new installation, both apps are permanently stuck on:

Unable to connect to Home Assistant Retrying in 60 seconds

The error screen only provides the button “Retry now”. There is no troubleshooting button, settings button, server selection, logout, or re-authentication option.

The apps appear to keep using refresh tokens from the previous Home Assistant installation. The new Home Assistant server rejects these tokens, but the Companion Apps do not start a new authentication flow.

Home Assistant server logs

The server repeatedly records failed authentication requests from both devices.

Examples:

Requested URL: '/auth/token' Home Assistant/2026.7.2 Alamofire/5.12.0

and:

Requested URL: '/api/websocket' Home Assistant/2026.7.2 Mobile/HomeAssistant

The iPad is separately identified on the local network, so the issue has been reproduced independently on two Apple devices.

Steps to reproduce

  1. Connect the Home Assistant Companion App to an existing Home Assistant installation.
  2. Completely reinstall or rebuild Home Assistant so that the old refresh tokens are no longer valid.
  3. Open the previously configured Companion App.
  4. The app attempts to use the old token.
  5. Home Assistant rejects the request to /auth/token.
  6. The app remains permanently on the “Unable to connect” screen with only “Retry now”.
  7. No re-authentication or server reset flow is offered.

Troubleshooting already performed

  • Confirmed that Home Assistant is reachable through Safari on the same iPhone and iPad.
  • Confirmed that login through Safari works with the new Home Assistant user account.
  • Confirmed that local and external access to Home Assistant work.
  • Completely deleted the Companion App from the iPhone.
  • Restarted the iPhone.
  • Reinstalled the Companion App.
  • Updated the Companion App from 2026.7.1 to 2026.7.2.
  • The issue remains unchanged.
  • The same issue occurs independently on the iPad.
  • The server logs confirm that both apps reach Home Assistant but submit invalid authentication credentials.

Expected behavior

When the stored refresh token is rejected, the Companion App should:

  • automatically start the Home Assistant authentication flow, or
  • show a re-authentication button, or
  • provide a way to remove/reset the saved server configuration.

Deleting and reinstalling the app should also provide a reliable method to clear the invalid saved credentials.

Actual behavior

The app continuously retries the invalid credentials and provides no way to leave the error screen.

Impact

This prevents use of the Home Assistant Companion App on both available Apple devices.

It also blocks:

  • registering the devices with the mobile_app integration,
  • Home Assistant push notifications,
  • importing Apple Thread credentials into Home Assistant,
  • commissioning a Matter-over-Thread smoke detector.

Additional context

The Home Assistant mobile_app integration currently has no registered devices because neither Apple device can complete authentication after the Home Assistant reinstall.

The issue appears to be related to stale credentials retained in the Apple Keychain or app configuration and a re-authentication flow that is not triggered when /auth/token rejects the old refresh token.

I found a working workaround. On the connection error screen, I tapped “Open App Settings”, removed the old Home Assistant server entry, and added the server again. Authentication then worked immediately, and the iPhone was successfully registered through the mobile_app integration.

Deleting and reinstalling the app had not cleared the old server configuration. The app should ideally offer this server-reset or re-authentication option more prominently when a stored refresh token is rejected.

Hi @markussingerforhomeassistant - where did you find "Open App Settings"? I am on iOS latest and using the current release version from the App Store.

sxdjt avatar Aug 04 '26 15:08 sxdjt

Hi, the “Open App Settings” link was not initially visible on my error screen either.

While I was on the “Unable to connect” screen, I swiped with three fingers. After that, the error screen changed and showed “Open App Settings” below “Retry now”.

I then opened the app settings, removed the old Home Assistant server entry, added the server again, and authentication worked immediately.

I believe it was a three-finger upward swipe, but I also tried different three-finger swipe directions, so I cannot confirm the exact direction with complete certainty. I was using the current App Store release, not TestFlight.

Open settings can be found:

  • Swiping up using 3 fingers
  • In the empty/error state
  • Through Shortcuts app using action "Open app settings"

bgoncal avatar Aug 04 '26 15:08 bgoncal

YES! THANK! YOU! @markussingerforhomeassistant and @bgoncal!!

sxdjt avatar Aug 04 '26 16:08 sxdjt

This "workaround" does not work for me. although I can access the hidden app settings using the three-finger gesture.

Environment:

Home Assistant Companion App 2026.7.2, build 2026.2446 iOS 26.5.2 Home Assistant is reachable from Safari on the same iPhone The user can log in successfully through Safari

What I tested:

Opened the hidden app settings using the three-finger gesture. Removed the saved Home Assistant server. Also tried the full “App Reset” action. Removed the corresponding iPhone device from the Mobile App integration in Home Assistant. Added the server again and entered the correct username and password when the login window appeared.

Observed result:

Immediately after “App Reset”, the server list is empty. If I close the app without adding anything and then reopen it, the old server automatically reappears. Home Assistant continues to log invalid authentication attempts from the iPhone to both /auth/token and /api/websocket. Even when the login window opens and valid credentials are entered, the app continues attempting authentication with the invalid stored credentials instead of completing a fresh authentication flow. The app is still unusable, although browser login works normally.

This seems important because the reset/removal workaround is therefore not reliable in all cases. In my case, “App Reset” clears the visible server list only temporarily; the previous server and authentication state return after restarting the app.

Could the users for whom the workaround succeeded clarify the exact sequence they used and whether the old server remained deleted after fully closing and reopening the app?

aburzynski avatar Aug 05 '26 10:08 aburzynski

Thanks, @markussingerforhomeassistant ! I deleted server, re-added, and it's working fine.

Alohajr avatar Aug 06 '26 02:08 Alohajr

Describe the bug

After the app has been backgrounded for an extended period (~30 min in this case), returning to the foreground fails to re-establish a working connection. The WebSocket disconnects with HAKit.HAReconnectManagerError.lateFireReset, and the app then gets stuck in a waitingToReconnect state referencing an already-expired auth token, rather than requesting a fresh one. Local frontend access via browser/DNS also becomes unreachable at the same time (Nabu Casa remote access is unaffected).

The only reliable workarounds are:

  • Force-closing and reopening the app, or
  • Clearing the app's cache/site data entirely

Both force a clean reconnect, suggesting the automatic reconnect/token-refresh logic doesn't recover cleanly from a long background period on its own.

Steps to reproduce

  1. Open the app, let it connect normally.
  2. Background the app (switch away/lock phone) for roughly 30+ minutes.
  3. Return to the app.
  4. Observe the WebSocket fails to reconnect automatically; local access also fails until cache is cleared or the app is force-closed and reopened.

Log evidence

10:42:34.595 [Info] [WebhookManager.swift:227] sendEphemeral > event_type: "ios.entered_background"

[~31 minute gap in logs — app suspended by iOS]

11:13:24.436 [Info] [Environment.swift:72] init() > WebSocket: disconnecting; permanently: default,
  error: Optional(HAKit.HAReconnectManagerError.lateFireReset)

11:13:24.498 [Info] [HAAPI.swift:290] connectWebSocketIfNeeded() > skipping automatic websocket
  connect while state is disconnected(reason: HAKit.HAConnectionState.DisconnectReason.waitingToReconnect(
  lastError: Optional(HAKit.HAReconnectManagerError.lateFireReset),
  atLatest: 2026-08-07 10:13:24 +0000, retryCount: 1))

Prior to this, on a separate occasion, repeated log lines of the form:

Token ... is expired by 192 seconds

were seen alongside request timeouts to the local instance (http://192.168.x.x:8123/api/states, NSURLErrorCode -1001), consistent with the reconnect attempt using a stale token rather than refreshing it.

Environment

  • App version: 2026.7.3 (build 2026.2546)
  • iOS version: 26.5.2
  • Device: iPhone 18,2
  • Home Assistant Core: 2026.7.x (Nabu Casa remote access + local access both configured)
  • Connection method affected: Both local (direct LAN URL) and briefly implicated in remote reconnect handling; Nabu Casa cloud URL used for reconnect in the log above

Additional context

This appears related to longstanding reports of similar behavior (e.g. #3879, #3626, #2453) — WebSocket/reconnect not recovering cleanly after periods of inactivity or backgrounding, with force-close/reopen as the only fix. This report is to flag the specific lateFireReset error signature, which didn't appear to be captured in those existing threads.

Update: frequency and workaround durability A subsequent server log covering roughly a 12-hour period showed 6 separate episodes of the app repeatedly hitting /auth/token with invalid/expired auth, each episode triggering multiple homeassistant.components.http.ban warnings in quick succession (e.g. 17:59, 20:22, 22:25, 02:47, 05:46, 05:50). Several episodes occur overnight, consistent with the pattern of the token expiring while the app is backgrounded for an extended period. Also worth noting: deleting the server from the app and re-adding it (a more drastic version of the force-close workaround) does clear the issue temporarily, but it recurs within hours — it is not a lasting fix, just a reset of whatever state gets corrupted.

WillWiggle avatar Aug 08 '26 05:08 WillWiggle

I found a working workaround. On the connection error screen, I tapped “Open App Settings”, removed the old Home Assistant server entry, and added the server again. Authentication then worked immediately, and the iPhone was successfully registered through the mobile_app integration.

Deleting and reinstalling the app had not cleared the old server configuration. The app should ideally offer this server-reset or re-authentication option more prominently when a stored refresh token is rejected.

Unfortunately, this workaround did not work for me. Confirming that delete/reinstall does not help either. This is really a bad situation. In my case, this was a first installation of the HA iOS app with a previously unused non-admin user account in HA. I cannot be sure that the initial password entry had a typo, but not being able to recover is a hard sell to new users. (This was the moment I introduced HA to my partner and now HA's reputation is tainted in their eyes).

The UI should also allow to interrupt this cycle of retries and have an "open settings" button that does not require a magic 3-finger swipe in that case.

ScriptHippie avatar Aug 15 '26 06:08 ScriptHippie

This flow has already been improved, but it's currently on beta testing and not available on App Store yet, so for now what is possible is to swipe up using 3 fingers, remove your server, add it back once again.

bgoncal avatar Aug 15 '26 08:08 bgoncal

Confirming this on app 2026.7.4 (build 2026.2715), iOS 26.6.0 — so the affected range extends past 2026.7.2.

I have the server side of this, which may help narrow it down.

Variation on the repro: the server was never reinstalled

In my case Home Assistant was not reinstalled or rebuilt. It is the same long-running instance it always was. The user account the app had been associated with was changed server-side, which invalidated the app's refresh token. That alone was enough to trigger this — so the trigger appears to be "the refresh token stops being valid", not "the server was reinstalled". That may widen the repro usefully.

What the server sees

Over ~50 minutes, 353 requests, all to the same endpoint, all rejected:

WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with
invalid authentication from localhost (127.0.0.1). Requested URL: '/auth/token'.
(Home Assistant/2026.7.4 (io.robbie.HomeAssistant; build:2026.2715; iOS 26.6.0) Alamofire/5.12.0)

Two things worth highlighting:

1. The app never attempts a login. Every single request is to /auth/token. There is not one request to /auth/login_flow/... in the entire period. So the app is not failing a credential check — it never reaches one. It only ever replays the stored token, gets refused, and retries.

2. The retries are not user-driven. They continued at 30–45 second intervals with nobody touching the phone. Tapping "Retry now" simply adds a burst of 2–3 on top of the background loop.

I also confirmed the server is not refusing the account: it is active, login enabled, not local-only; there is no ip_bans.yaml; and there is no http: configuration (so no ip_ban_enabled, no login_attempts_threshold). Nothing server-side is blocking it — the token simply does not exist any more, which correctly returns 400 invalid_grant.

At the time of observation the instance's auth store held no refresh token with client_id: https://home-assistant.io/iOS at all, and no mobile_app config entry for that user, while the app went on retrying against it indefinitely.

Note for anyone triaging from server logs

That http.ban warning is misleading here. homeassistant/components/http/ban.py calls process_wrong_login() on any response status >= 400, not just 401/403:

if resp.status >= HTTPStatus.BAD_REQUEST:
    await process_wrong_login(request)

So "Login attempt or request with invalid authentication" is logged for a plain 400 invalid_grant on a dead refresh token, with no user, no username and no password involved. The Requested URL is what distinguishes them: /auth/login_flow/... is a real credential check, /auth/token is a token exchange. Several similar-looking reports may be this rather than actual failed logins.

Client behaviour that turns this into a dead end

  • The app treats 400 invalid_grant as a retryable connection failure rather than an auth failure, so it never drops to re-authentication.
  • The error screen offers only "Retry now" — no settings, no server list, no logout, as already described here.
  • Deleting and reinstalling the app does not clear it. I did this four times. The saved server config comes back every time, which suggests it is being restored from iOS backup/keychain rather than living only in the app container.

That last point is what makes this unrecoverable from the user's side: there is no in-app escape hatch, and the usual out-of-app one (reinstall) does not work either. The app is currently uninstalled here because there is no way to get past it.

skm7463 avatar Aug 19 '26 11:08 skm7463

There is a way out of the "Retry now" screen. Posting it because the issue currently states there is none, and it took about two minutes.

Workaround: make the stuck server unreachable

The wedged server entry had exactly one route to Home Assistant — the Nabu Casa tunnel. Turning Remote Control off in Home Assistant Cloud settings removed it. With no reachable route, the app stopped retrying the stale token and dropped back to onboarding, offering to add a server.

From there:

  1. Add the new/correct server.
  2. Delete the old entry — the app's normal Settings → Servers UI is reachable again, because you are no longer trapped on the error screen.
  3. Turn Remote Control back on.

Confirmed working: the phone is now registered against the intended instance, and the old instance shows no stale tokens or mobile_app entries.

Two caveats: you lose remote access for the minute or two it takes, and remote_allow_remote_enable needs to be left on so you can switch it back from anywhere.

The general form is remove every path the stuck entry can reach, so it should apply beyond Nabu Casa — a firewall rule against the LAN address, or simply stopping Home Assistant, ought to have the same effect for a locally-reached server. I only tested the cloud case.

Why this may point at the fix

The app clearly already has the recovery path — it falls back to onboarding perfectly well once the server is unreachable. It just never reaches that path from a 400 invalid_grant on token refresh, which it appears to treat as a retryable connection failure rather than an authentication failure.

So the fix may be narrow: on 400 invalid_grant from /auth/token, treat the stored credentials as dead and drop into the same re-onboarding flow that an unreachable server already triggers.

Still present in 2026.7.5

For the record, this reproduced unchanged on 2026.7.5 (build 2026.2744) before the workaround — so 7.5 does not fix it. Deleting and reinstalling the app still does not clear the stuck entry; four attempts here made no difference.

skm7463 avatar Aug 22 '26 12:08 skm7463

Thank you for the great solution to get my HA app working again after i changed the password.

Below the solution for Iphone and Ipad. Hi, the “Open App Settings” link was not initially visible on my error screen either.

While I was on the “Unable to connect” screen, I swiped with three fingers. After that, the error screen changed and showed “Open App Settings” below “Retry now”.

I then opened the app settings, removed the old Home Assistant server entry, added the server again, and authentication worked immediately.

I believe it was a three-finger upward swipe, but I also tried different three-finger swipe directions, so I cannot confirm the exact direction with complete certainty. I was using the current App Store release, not TestFlight.

FlodderBit avatar Aug 22 '26 13:08 FlodderBit

OH MY GOD. Thanks @markussingerforhomeassistant !! The three finger upward swipe saved me after changing my password on the laptop (a VERY COMMON thing to do that really should not incur an app failure unrecoverable without a Github search, lol). There’s no way in a billion years I would have ever tried or discovered that (I don’t really use the “magic” Apple gestures). Glad to see this seems addressed in an upcoming release. (I’m enjoying my HA experience so far and I appreciate all the hard work that has gone into it, snark aside, but gosh this was a silly edge case 😅)

codebykat avatar Aug 29 '26 19:08 codebykat

I have the same issue. If I change the password on the server, I just get stuck in an infinite reconnect retry loop on the app. There is no easy way to change/confirm password. I just gave up, deleted the server, and readded the server. The user experience is not intuitive here at all.

polskikrol avatar Sep 09 '26 17:09 polskikrol

This was fixed in #5348, merged August 4, 2026. The fix triggers re-authentication when the server rejects a saved access token. It shipped in Companion app 2026.8.0. Closing.

../Frenck

                       

Blogging my personal ramblings at frenck.dev

This was done with AI, in case of an error, please let me know.

frenck avatar Oct 10 '26 12:10 frenck