iOS icon indicating copy to clipboard operation
iOS copied to clipboard

Cannot connect to HA in Companion App via Internal URL

Open merryflag4173 opened this issue 8 months ago • 22 comments

iOS device model, version and app version

Model Name: iPad Pro (11-inch) (3rd generation) Software Version: 18.5 App version: 2025.5

Model Name: iPhone 11 Pro Software Version: 18.5 App version: 2025.5

Home Assistant Core Version

2025.5

Describe the bug I am unable to connect to my HA instance via Internal URL. External URL works (via HA Cloud). I'm also able to connect to the Internal URL from my laptop.

To Reproduce

  • Enter Internal URL under Settings > Companion app > Home > Internal URL
  • Quit app & relaunch
  • App does not connect to HA

Expected behavior

  • App should connect to HA

Screenshots

Additional context

merryflag4173 avatar May 20 '25 23:05 merryflag4173

Can you connect to this internal URL using iOS Safari? Any security warnings it gives you?

bgoncal avatar May 21 '25 08:05 bgoncal

Hi! See below for the screenshots of what I get (Mac, iPhone, iPad):

  

The iPhone looks to be connecting successfully, but the iPad is not. All devices are connected to the same SSID & do not have any VPN on.

On May 21, 2025, at 1:35 AM, Bruno Pantaleão Gonçalves @.***> wrote:

bgoncal left a comment (home-assistant/iOS#3608) https://github.com/home-assistant/iOS/issues/3608#issuecomment-2897090005 Can you connect to this internal URL using iOS Safari? Any security warnings it gives you?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/iOS/issues/3608#issuecomment-2897090005, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLHFM7TIWUPSSRFS5WCT3NT27Q3E3AVCNFSM6AAAAAB5RXGB52VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOJXGA4TAMBQGU. You are receiving this because you authored the thread.

merryflag4173 avatar May 21 '25 16:05 merryflag4173

Your images weren't uploaded to GitHub, can you try again?

bgoncal avatar May 22 '25 07:05 bgoncal

I think I am encountering the same issue. The new app isn't respecting the scheme defined when connecting to a server. I specify https://servername when adding the server but: In nginx access log, I see 301 redirects to HTTPS on the /api/websocket endpoint In the app I get a Starscream.HTTPUpgradeError In the exported app logs I see [Error] [main] [Environment.swift:75] init() > WebSocket: Error: Optional(Starscream.HTTPUpgradeError.notAnUpgrade(301, ["Server": "nginx/1.26.3 (Ubuntu)", "Content-Type": "text/html", "Date": "Mon, 26 May 2025 03:17:41 GMT", "Connection": "keep-alive", "Location": "https://dev-hass.makerland.xyz/api/websocket", "Content-Length": "178"])) With TCPdump I see traffic going to port 80 04:05:09.417593 eth0 In IP 10.3.5.140.52083 > hass02.makerland.xyz.http: Flags [S], seq 600926463, win 65535, options [mss 1460,nop,wscale 6,nop,nop,TS val 4049053127 ecr 0,sackOK,eol], length 0 In the configuration.yaml, I've defined the URLs with HTTPS also. HTTP isn't mentioned anywhere but starscream is trying to connect via insecure websocket. Not sure if that makes it a bug better suited for the starscream repo. I can't tell if it's a bug in the implementation of the library or the lib itself. Swift is up there with the programming languages that confuse me the most.

charlespick avatar May 26 '25 04:05 charlespick

Actually now that I think about it, this might not be related. The original poster probably isn't using https. I will open a new issue if nobody tells me otherwise.

charlespick avatar May 26 '25 04:05 charlespick

My iOS Home Assistant Companion app stopped working today. I can still connect to my HA server (a local Raspberry Pi) via browsers from my laptop, but not from Safari or from the app on my iPhone. Perhaps it is an iOS issue.

iOS version: 18.5 Home Assistant Companion version: 2025.5 (2025.1264)

Safari says: Safari couldn't open the page because the server stopped responding.

When I try to add a server from the app, it cannot find any servers. When I try to add the server URL manually I get:

We couldn't connect to Home Assistant ... Description: The request timed out. Domain: HomeAssistant.OnboardingAuthError Code: 1

PeterPudney avatar May 28 '25 04:05 PeterPudney

I had the same problem after I sent a notification from Home Assistant to my iOS app for the first time. As a result, the Home Assistant app could no longer find the local server. The homekit bridges were also no longer accessible from the Apple home app. Resetting the network connections on the iPhone fixed the problems.

yz88 avatar Jun 30 '25 16:06 yz88

I'm having the same issue. I think my issue is partially related to the fact that I'm using old hardware/OS.

I have a new iPadAir with newest iPadOS and it is working fine there. However, the following are having problems: My MacBook Air M1 is on MacOS Monterey v12.7.6. My iPhone XS Max is on iOS 17.4.1 My iPad Pro 3 is iPadOS 17.7

Now the weird part is that, if I connect my laptop to the internet using internet sharing from my iphone, then I can access the homeAssistant from outside fine, but internally only the new devices connect fine.

On my MacBook Air, I have the app for MacOS. here are the errors I get with it:

Description: 
 
Invalid HTTP response (403) for http://192.168.xxx.xxx:8123/auth/authorize?response_type=code&client_id=https://home-assistant.io/iOS&redirect_uri=homeassistant://auth-callback. 
 
Domain: 
 
HomeAssistant.OnboardingAuthError 
 
Code: 
 
1 

here is also part of the log from the app:

2025-07-09 16:13:13.731 [Info] [main] [PeriodicUpdateManager.swift:57] connectAPI(reason:) > Connect finished for reason warm
2025-07-09 16:13:20.958 [Verbose] [main] [OnboardingServersListViewModel.swift:85] selectInstance(_:controller:) > Selected instance DiscoveredHomeAssistant(uuid: Optional("xxxx"), version: 2025.5.0, internalOrExternalURL: http://192.168.xxx.xxx:8123, externalURL: Optional(https://xxx.duckdns.org), internalURL: Optional(http://192.168.xxx.xxx:8123), locationName: "Home", bonjourName: Optional("Home"))
2025-07-09 16:13:20.984 [Info] [main] [OnboardingAuth.swift:81] performPreSteps(checkPoint:authDetails:sender:) > beforeAuth
2025-07-09 16:13:20.984 [Verbose] [main] [OnboardingAuthStepConnectivity.swift:25] perform(point:) > 
2025-07-09 16:13:21.142 [Info] [main] [OnboardingAuth.swift:71] perform(checkPoint:checks:) > OnboardingAuthStepConnectivity: rejected(HomeAssistant.OnboardingAuthError(kind: HomeAssistant.OnboardingAuthError.ErrorKind.other(<NSHTTPResponse> {
    Body = "403: Forbidden";
    Headers =     {
        "Content-Length" = 14;
        "Content-Type" = "text/plain; charset=utf-8";
        Date = "Wed, 09 Jul 2025 13:13:21 GMT";
        Server = "Python/3.13 aiohttp/3.11.18";
    };
    "Status Code" = 403;
    URL = "http://192.168.xxx.xxx:8123/auth/authorize?response_type=code&client_id=https://home-assistant.io/iOS&redirect_uri=homeassistant://auth-callback";
}), data: Optional(14 bytes)))
2025-07-09 16:13:21.142 [Info] [main] [OnboardingAuth.swift:81] performPreSteps(checkPoint:authDetails:sender:) > beforeAuth
2025-07-09 16:13:21.142 [Verbose] [main] [OnboardingAuthStepConnectivity.swift:25] perform(point:) > 
2025-07-09 16:13:21.187 [Info] [main] [OnboardingAuth.swift:71] perform(checkPoint:checks:) > OnboardingAuthStepConnectivity: rejected(HomeAssistant.OnboardingAuthError(kind: HomeAssistant.OnboardingAuthError.ErrorKind.other(<NSHTTPResponse> {
    Body = "403: Forbidden";
    Headers =     {
        "Content-Length" = 14;
        "Content-Type" = "text/plain; charset=utf-8";
        Date = "Wed, 09 Jul 2025 13:13:21 GMT";
        Server = openresty;

Tonguc-Endem avatar Jul 09 '25 13:07 Tonguc-Endem

Any chance your IP was banned in HA? Since when you connect through your phones hotstop (IP changes) it succeeds

bgoncal avatar Jul 09 '25 13:07 bgoncal

Yes, my problem apparently was ip_bans.yaml. After going through everything for hours through NginxPM, DNSMasq, SSL, etc and I even installed a new HAOS vm on ProxMox, (current is on Pi4) I finally realized the problem is ip_bans. I removed the entries in it and restarted HA and it worked but the problem is this keeps happening. The great thing is that there is no ip_bans_whitelist.yaml or something like that. I found this ban_allowlist and I will give it a try.

Another thing is that I had to delete site data from chrome. click icon on address bar, click site-settings, then delete data. Did it both for ip and https name. Chrome was using expired certificate for some reason.

I hope this helps someone.

Tonguc-Endem avatar Jul 10 '25 04:07 Tonguc-Endem

iOS device model, version and app version

Model Name: iPad Pro (11-inch) (3rd generation) Software Version: 18.5 App version: 2025.5

Model Name: iPhone 11 Pro Software Version: 18.5 App version: 2025.5

Home Assistant Core Version

2025.5

Describe the bug I am unable to connect to my HA instance via Internal URL. External URL works (via HA Cloud). I'm also able to connect to the Internal URL from my laptop.

To Reproduce

  • Enter Internal URL under Settings > Companion app > Home > Internal URL
  • Quit app & relaunch
  • App does not connect to HA

Expected behavior

  • App should connect to HA

Screenshots

Additional context

mervyxxx avatar Aug 01 '25 18:08 mervyxxx

I am also unable to connect to HA using the internal URL http://homeassistant.local:8123 or via IP address from an iOS device. I do not have an external URL for access outside of my local network.

Model Name: iPhone 16e Software Version: 18.6 App version: 2025.7.2

Home Assistant Core Version

2025.7.4

Describe the bug

The iOS app will not connect to my HA server by its IP address or the local URL http://homeassistant.local:8123.

To Reproduce

  • Install a fresh copy of the HA iOS app (to ensure no previous servers)
  • Click "Enter address manually", the server on the local network is not detected automatically
  • Enter the URL http://homeassistant.local:8123 or the IP-address equivalent
  • Click the "Connect" button
  • Receive error: "A server with the specified hostname could not be found."

Expected behavior

  • The app connects and displays the default dashboard.

Screenshots

Additional context

I do not have an ip_bans file.

ryanerato avatar Aug 01 '25 19:08 ryanerato

@ryanerato can you access that IP in iOS Safari?

bgoncal avatar Aug 01 '25 20:08 bgoncal

@ryanerato can you access that IP in iOS Safari?

Yes, both the local URL and IP address work in Safari on both iOS and macOS.

ryanerato avatar Aug 01 '25 20:08 ryanerato

Try this:

  • if you have server configured, remove them from the app.
  • Update app to 2025.7.2
  • Reboot
  • Double check your "local network" permission is enabled
  • Launch the app and setup again using the IP

bgoncal avatar Aug 02 '25 08:08 bgoncal

Try this:

* if you have server configured, remote them from the app.
* Update app to 2025.7.2
* Reboot
* Double check your "local network" permission is enabled
* Launch the app and setup again using the IP

This worked, though I had to completely remove the iOS app from my device and re-install it. I wasn't able to remove any previously configured server as the app would jump straight into the onboarding screen.

Once I reinstalled, the app was able to auto-detect my HAOS server, though it defaulted to the IP address instead of using mDNS. Everything otherwise appears to be working again.

ryanerato avatar Aug 06 '25 17:08 ryanerato

Have the same problem. Since some days mobile app stopped working. I can still login via pc (Linux and brave browser) but iOS app stopped working.

Invalid HTTP response (403) for http://192.168.188.46:8123/auth/authorize?response_type=code&client_id=https://home-assistant.io/iOS&redirect_uri=homeassistant://auth-callback.

albertusQuelle avatar Sep 09 '25 16:09 albertusQuelle

I just hit the bug - for me, the app didn’t ask permission to use the local network and failed discovering the ha green. Uninstalling the app completely and opening it did ask for permission and was then able to connect.

peasus avatar Sep 25 '25 03:09 peasus

I've been having similar issues to this after replacing my router - the iOS app was unable to connect, and after uninstalling & reinstalling the app to start with a clean slate, it wouldn't fully load the login page in the app after entering the local IP address for Home Assistant. It would show the HA logo in the login webview after about a 30s delay, but otherwise was a completely blank screen below that. I was able to access the login page in iOS safari using the same local IP, but it would hang forever after logging in.

Turns out mDNS forwarding was disabled at the network level, and apparently that caused all of the issues above for me. I'm not entirely sure what the root cause was that triggers those issues when mDNS isn't available, because I was manually entering the IP address so I didn't expect DNS to be required, but after enabling mDNS again it autodetected instantly (no need to enter manually, although it detects the exact same IP address that I was using) and allows the login as normal.

Disabling mDNS again on the router after logging in to the HA app doesn't appear to cause any additional problems - once it's logged in it works as expected just via the IP address, so it seems to just be an issue with that initial authentication flow.

gtebbutt avatar Sep 28 '25 19:09 gtebbutt

also have this problem. done numerous things to try and connect. verified that the local and remote urls are set and correct, removed the ios companion appp & data, re-added it. verified the settings in HA -> general and network.

Nothing works and IOS is unable to connect to the ha instance USING THE APP, no problem at all using the IOS safari browser.

curl, telnet, web browsers all succeed but the IOS always fails with the same error.

Seems that it is completely broken now, pretty sure this is ssl related and I suspect that it's probably as the request is made from http connection and the ha auth is calling https:// for the auth check: https://home-assistant.io/ as below

Invalid HTTP response (403) for http://xx.xx.xx.xx:8123/auth/authorize?response_type=code&client_id=https://home-assistant.io/iOS&redirect_uri=homeassistant://auth-callback. 

And yes, Local Network Permission is granted to HA in IOS, I am on the latest versions of HA and IOS and the IOS app, have restarted HA and the host numerous times, as far as I can tell this app is now dead.

Probably the ha dev team are running their ha instances on https.

And also, after deleting the app & data & re-installing, it is impossible to set the ssid as you can only try and connect to an existing instance, there is no option to define the local and remote urls or SSID on a fresh install under IOS, that is a bug for sure.

I just ran the HA companion app on OSX and it succeeded the first time, so pretty sure this is an IOS HA bug.

Given up now, spent 3 hours on this with no progress at all.

pacmac avatar Nov 18 '25 01:11 pacmac

I just had the same experience with one of two iPhones. Background: I separated out VLANs and WiFis, so I had to change the connections in the companion apps. In the first iPhone I tried to change the existing connection and set the WiFi to the new SSID. Then I removed the old server, added the new one and that worked.

On the second iPhone I deleted the old server first, and then the new onboarding experience just would not work. What definitely seems broken is the entering of URLs manually, as apparently this doesn't let you change your SSID from previous attempts.

I tried rebooting the iPhone, reinstalling the App multiple times, no success.

Only way I got it to work was to change WiFis to the one which is on the same VLAN as HA, then autodiscovery (probably via mDNS) worked. After switching back to the other WiFi setting the proper home SSID, everything works fine again.

AckermannM avatar Nov 30 '25 20:11 AckermannM