External access - keeps loading data after password

Hi,

I have HA running with port forwarding and password protection (will enable dns and lets encrypt later). My problem is that when im accessing HA over the WAN IP and type in the password, it just keep “loading data” without progressing to default view.

If i go in via the local address, write the password, it immediatly works. Also, if i disable the password, go in via the WAN IP, it also works.

I also experience the local connection much faster and both in loading and handling of switches. This despite sitting behind 100mbit fiber…

I have no idea how to solve this. Any ideas?

Try clearing browser cache

What HA version?

Hi,

I tried clearing the cache as well as cookies. Running 0.37 (had the same issue on 0.36).

I noticed today that if i access HA from outside, cellular for example, there is no issue. So this only occur when im accessing HA over a WAN IP from a local address on my wifi.

Right now, the thinking goes if there is any problem with this set up related to “point of origin” or the websockets that HA is using.

I will try to activate TLS tonight and see if that can sort out the point of origin. Ideas?

Enabled SSL and also duckdns. no joy…

Again, using wifi, im reaching the login screen using hostname but after typing the password it just keeps “loading”.

And also, again, using a public internet doing the same, then it works perfectly.

Ideas is greatly appreciated. log below (from what I believe is related)

31 22:09:36 INFO (MainThread) [homeassistant.components.http] Serving /api/websocket to 192.168.1.107 (auth: False)
17-01-31 22:09:36 INFO (MainThread) [homeassistant.components.http] Serving /api/bootstrap to 192.168.1.107 (auth: True)
17-01-31 22:09:39 INFO (MainThread) [homeassistant.components.http] Serving / to 192.168.1.107 (auth: False)
17-01-31 22:09:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 131, in _sendfile_fallback
yield from resp.drain()
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_reqrep.py”, line 888, in drain
yield from self._resp_impl.transport.drain()
File “/usr/lib/python3.4/asyncio/streams.py”, line 299, in drain
yield from self._protocol._drain_helper()
File “/usr/lib/python3.4/asyncio/streams.py”, line 197, in _drain_helper
yield from waiter
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_server.py”, line 61, in handle_request
resp = yield from self._handler(request)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web.py”, line 249, in _handle
resp = yield from handler(request)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/static.py”, line 62, in static_middleware_handler
resp = yield from handler(request)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_urldispatcher.py”, line 486, in _handle
ret = yield from self._file_sender.send(request, filepath)
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 201, in send
yield from self._sendfile(request, resp, f, count)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/static.py”, line 30, in sendfile
yield from orig_sendfile(request, resp, fobj, count)
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 60, in _sendfile_system
yield from self._sendfile_fallback(request, resp, fobj, count)
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 137, in _sendfile_fallback
resp.set_tcp_nodelay(True)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_reqrep.py”, line 737, in set_tcp_nodelay
resp_impl.transport.set_tcp_nodelay(value)
File “/home/homeassistant/.homeassistant/deps/aiohttp/parsers.py”, line 253, in set_tcp_nodelay
self._socket.setsockopt(socket.IPPROTO_TCP, CORK, False)
OSError: [Errno 9] Bad file descriptor
17-01-31 22:09:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 131, in _sendfile_fallback
yield from resp.drain()
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_reqrep.py”, line 888, in drain
yield from self._resp_impl.transport.drain()
File “/usr/lib/python3.4/asyncio/streams.py”, line 299, in drain
yield from self._protocol._drain_helper()
File “/usr/lib/python3.4/asyncio/streams.py”, line 197, in _drain_helper
yield from waiter
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_server.py”, line 61, in handle_request
resp = yield from self._handler(request)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web.py”, line 249, in _handle
resp = yield from handler(request)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/static.py”, line 62, in static_middleware_handler
resp = yield from handler(request)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_urldispatcher.py”, line 486, in _handle
ret = yield from self._file_sender.send(request, filepath)
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 201, in send
yield from self._sendfile(request, resp, f, count)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/http/static.py”, line 30, in sendfile
yield from orig_sendfile(request, resp, fobj, count)
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 60, in _sendfile_system
yield from self._sendfile_fallback(request, resp, fobj, count)
File “/home/homeassistant/.homeassistant/deps/aiohttp/file_sender.py”, line 137, in _sendfile_fallback
resp.set_tcp_nodelay(True)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_reqrep.py”, line 737, in set_tcp_nodelay
resp_impl.transport.set_tcp_nodelay(value)
File “/home/homeassistant/.homeassistant/deps/aiohttp/parsers.py”, line 253, in set_tcp_nodelay
self._socket.setsockopt(socket.IPPROTO_TCP, CORK, False)
OSError: [Errno 9] Bad file descriptor

So, trying to understand your troubles. It seems as if outside your network, you can access HA with your WAN IP. You can access your HA inside your network with your local IP but you cannot access HA inside your network with your WAN IP. Is that correct?

I assume you’re trying to set it up so that you only have one URL/IP address for both internal and external use. Is that correct?

Hi

Exactly. Would like to use it seamlessly using WiFi and from other networks.

This issue is with how port forwarding works and that is why you can’t access internally with you external IP even with port forwarding. The way I achieved what you are trying to do is installed Pi-Hole. Besides it being the easiest way I could find, I also get the advantage of a network wide ad blocker. Really though, all you need is DNSmasq. Basically, what needs to happen is when you type your duckdns URL or WAN IP if it is static, into a browser while on your network, you need a system to translate that into the internal IP address.

I use a RPi3 for my setup. I run HA and Pi-hole on the same pi. Installing Pi-hole is very straight forward. Once it is install you’ll need to edit your /etc/host file to include 127.0.0.1 yoururl.duckdns.org. This tells pi-hole/dnsmasq that your URL is hosted locally and should be redirected there. You’ll also need to change your router’s DNS server to the raspberry pi’s internal IP address. This tells every device on your network to use your Pi as its DNS lookup.

It sounds more complicated than it really is. You just need something on your internal network to grab traffic that is headed outside to access an inside device and redirect it internally to that device instead of letting it out.

1 Like