NSURLErrorDomain - 1004

I had a stupid mistake that caused this issue… My router does not support loopback so I use the DNSmasq add-on to help connect from my local network (might be the same issue for those not able to connect locally but able to connect remotely). I hadn’t noticed my phone switched to my long-range WIFI extender I use for a specific area a couple hundred feet from my house, which I did not have my DNSMasq DNS server setup on. This caused this issue. My mistake, switched back to regular wifi with the DNS server set properly and all is well again. So either look into using DNSmasq if your router doesn’t support loopback, and/or make sure your proper DNS server is set if you are using this.

I have the same Problems since months… sometimes every day, sometimes once a week… HA is not available and i got the message “could not connect tot the server NSURLErrorDomain - 1004”.
And then no devices work. Only a hard reboot helps. This made me sad… don’t if my raspi is broken or HA is not ok…

1 Like

+1 - started happening today. Turns out I had my phone connected to my extender, which is isolated from the network. No clue why it would cause this, as it should still resolve DNS normally, but apparently tried to route the request to a local address, somehow.

Same here. Ping via VPN to machine is okay. However no app, no web interface is working. No clue what happened

Same here…

Solved for me: ssl certificate was outdated. Doh.

I can ping my raspberry pi but i can’t connect to home-assistant. I try it via browser, app or ssh.

Hey,
i had the same issue for weeks. This solution worked for me:

  1. I used Pi Hole (on another Pi) and set it up to the main DNS-Server in my Router (i think it will be also possible with other tools like dnsmasq or freetz).
  2. I open the /etc/hosts file in the Pi hole Pi (login via ssh and type: sudo nano /etc/hosts).
  3. And add the following line: HOMEASSISTANT-IP:HA-PORT EXTERNALDOMAIN.duckdns.org

for example:
192.168.110.123:8123 domain-home-assistant.duckdns.org

Important was to add the Port at the end of to the IP. Without it won’t work.

1 Like

i had the same problem. after turning off my location service on my iphone, the problem was no longer there for me. I don’t know why this problem occurs, but turning it off solved it for me.

I had the same once I switched to using (internal) domain names using Nginx rather than IP addresses. It would work from outside, where the request was handled by the router and (port) forwarded to the right IP (in this case the server hosting Nginx)

Once on WIFI, it would not work and I got the 1004 error. I fixed it by updating my router’s DNS setting (dnsmasq) to forward all requests for my (sub)domain directly to the Nginx IP address.

Just in case someone has the same problem:
For me iOS had switched the full trust in Settings > General > About > Certificate Trust Settings off at some point, probably because I switched the device. This results in NSURLErrorDomain -1202, but this was the first thread I stumbled upon, so maybe it helps someone remember to check that as well!

I reckon there’s multiple possible causes for this error - but at least one of them appears to be having a (relatively) new iOS feature called “Limit IP Address Tracking” turned on for your home Wi-Fi. Added in iOS 15.2, I think.

Makes sense, given this feature makes Safari route web requests (including when Safari is embedded in an app) through an external proxy server - which obviously won’t have local access to your HA instance.

Happened to me this evening - experienced this error, realised the “Limit IP Address Tracking” feature had somehow been re-enabled on my home Wi-Fi network despite previously disabling it - and error went away when I turned it off again.

You can toggle this setting in Settings → Wi-Fi → tap the (i) icon next to your home Wi-Fi network (and scroll down). You’ll obviously lose the privacy benefits of this feature when on your home network (Google them if curious). In an ideal world you’d be able to exclude a specific domain name (your HA instance’s) on a specific network (your home Wi-Fi) from being covered by the Limit IP Address Tracking feature, but I don’t believe that’s possible.

4 Likes

Signed up to do this post, and I do realize it was started over a year ago. But I thought I would mention what my fix was for this issue. After trying options from others my situation was different, it was working fine over LTE. In the app you have the Internal URL and you have the External URL in the application. I noticed my IP was a 10.10.1.1/24. The app was looking for the Home Assistance instance, on the wrong network. Removed the Internal URL and that fixed the issue.

You could also just add the SSID for the network, so if the IP’s match it will know to look at the SSID.

Hope this helps!

3 Likes

I could not reach Home Assistant from anywhere, my iPhone, locally from my laptop, nothing worked.
after days of trying this helped. I connected a keyboard and monitor to my low cost NUC.

supervisor update

command did the trick

Yes,

This works! I just changed it to homeassistant.local:8123!

Just adding my fix in case it helps someone else. I was getting this error as well and resolved the issue by switching to safari browser from chrome.

Just came here to mention that on IOS17, Limit IP address tracking feature (under Wifi) will cause this too. Hope the HA dev’s can figure this out, as that is a clever and good feature from Apple.

2 Likes

I had the same issue out of nowhere. I fixed it by deleting the server on the companion app on my iPhone and then re-adding the server.
No idea why it broke, but this fixed it.

ssl where which ssl was outdated?

IOS related same error. It happened after update to 2024.05. But on a browser on Windows PC, it just says refused to connect.