Discovery: Network is unreachable (0.86 and up)

Starting with 0.86 and also 0.87, my logging is spawned every 5 minutes with the following message:

2019-02-08 14:25:34 ERROR (MainThread) [homeassistant.components.discovery] Network is unreachable
2019-02-08 14:30:35 ERROR (MainThread) [homeassistant.components.discovery] Network is unreachable
2019-02-08 14:35:36 ERROR (MainThread) [homeassistant.components.discovery] Network is unreachable

I am running in docker and “–net=host” … That worked in previous versions perfectly. Anybody an idea what i get this?

1 Like

Not sure, but I also just started getting this. Also running docker with the container in host networking mode

I should clarify, I only receive this error once when I restart HASS. Also, I can’t seem to discover my cast devices (not sure if related, but it seems to be)

I can confirm I have the same issue

Confirming I have the same issues. Log is flooded with that message every 5 minutes and I can no longer find my Google Cast devices. There are no network security settings set up to block access between the two and this started occurring in 0.86.
Error:

components/discovery.py (ERROR)
Network is unreachable

I change the Python code a bit, and i see the following error in the logging (OSError):
‘[Errno 105] No buffer space available’

I have seen this before, but not continuesly.

I typed the following command:
sysctl net.ipv4.igmp_max_memberships=40

And restart HASS … This solves it, because the max membership is by default 20.

3 Likes

Have had the same issue for quite some time. That command that you mentioned, did you run it in the HASS container or on the host OS?

I tried it on both and neither worked.

EDIT2: Bumped it to 80 and it seems to be working now. Hoping I don’t have to do this every time the container updates…

Yes, it needs to be done on the host OS. You can check/count the current ‘used’ ones with:
netstat -ng

(just check/count the 224.0.., the other ones are IPv6)

To make it permanent after each reboot, add it to the “/etc/sysctl.conf”.

Hmm, having issues doing this on freeBSD. Need to look into it further

I am having the same issue but on Windows 2012 R2

Any known fix?

I’m having a problem with my HASS installation on RPi 4 running docker in Libreelec. I using this fine on a RPi3 and I migrated to a new installation on RPi 4 copying all the userdata folders for docker and Portainer. Everything seems to run ok apart from discovery doesn’t work and I get the error in the log below. I’m running host network mode in docker and I’ve checked to make sure all services on Libreelec aren’t running as I know avahi running can conflict with HASS discovery.

2019-07-14 14:48:01 ERROR (MainThread) [homeassistant.components.discovery] Network is unreachable
2019-07-14 14:51:28 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 80, in create_connection
    raise err
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 70, in create_connection
    sock.connect(sa)
OSError: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1290, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1239, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 183, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xafb83dd0>: Failed to establish a new connection: [Errno 113] Host is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.0.40', port=8081): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xafb83dd0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 478, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 495, in handle
    image = await camera.async_camera_image()
  File "/usr/src/homeassistant/homeassistant/components/mjpeg/camera.py", line 107, in async_camera_image
    self.camera_image)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/mjpeg/camera.py", line 143, in camera_image
    req = requests.get(self._mjpeg_url, stream=True, timeout=10)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.0.40', port=8081): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xafb83dd0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))

I don’t think the raspberry pi 4 is supported yet based on their blog

Who’s blog? I’m running on Libreelec in a docker container and HASS works fine apart from discovery.

Sorry, haven’t had my coffee yet. Hassio doesn’t support raspberry pi 4 yet but looks like libreelec does have a beta. Unfortunately I never figured out my discovery issues

1 Like

Also the Pi 4 issue is related to “Host is unreachable”, this topic is around “Network is unreachable”. So different issues, sorry.

Does anyone of you happen to have Pihole running? In my case I am and I think it might be the culprit. Disabled Pihole now and testing with cloudflare dns to see if that works better.

I do…Hmm I’ll have to test this.

@fversteegen @dj21d - did you check the “netstat -ng” output and sysctl commands? If running multiple apps/containers, it is possible you go over such limit (on the main OS).

I did run it, but don’t know how to interpret it :upside_down_face: