hassio-addons / addon-pi-hole

Pi-hole - Home Assistant Community Add-ons
https://addons.community
MIT License
123 stars 40 forks source link

After a reboot Pi-hole loses connection and causes other connection issues #24

Closed nickmomrik closed 6 years ago

nickmomrik commented 6 years ago

Problem/Motivation

I rebooted my Raspberry Pi. When everything started back up Home Assistant was asking me to authenticate everything again, but wouldn't work. Eventually I disabled the Pi-hole addon and everything else started working again.

Expected behavior

I expect Pi-hole to work after a reboot.

Actual behavior

I can't get the addon to work again after several reboots and reinstalling the addon several times. When I start it, here is the log:

INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 03-version-requirements.sh: executing... 
[cont-init.d] 03-version-requirements.sh: exited 0.
[cont-init.d] 10-requirements.sh: executing... 
[cont-init.d] 10-requirements.sh: exited 0.
[cont-init.d] 11-patches.sh: executing... 
[cont-init.d] 11-patches.sh: exited 0.
[cont-init.d] 11-pihole.sh: executing... 
[cont-init.d] 11-pihole.sh: exited 0.
[cont-init.d] 12-dnsmasq.sh: executing... 
[cont-init.d] 12-dnsmasq.sh: exited 0.
[cont-init.d] 13-nginx.sh: executing... 
[cont-init.d] 13-nginx.sh: exited 0.
[cont-init.d] 14-password.sh: executing... 
  [✓] New password set
[cont-init.d] 14-password.sh: exited 0.
[cont-init.d] 15-hostname.sh: executing... 
[cont-init.d] 15-hostname.sh: exited 0.
[cont-init.d] 16-logfiles.sh: executing... 
[cont-init.d] 16-logfiles.sh: exited 0.
[cont-init.d] 17-hosts.sh: executing... 
[cont-init.d] 17-hosts.sh: exited 0.
[cont-init.d] 50-gravity.sh: executing... 
  [i] Neutrino emissions detected...
  [i] Pulling blocklist source list into range...

  [✓] Pulling blocklist source list into range
  [i] Target: raw.githubusercontent.com (hosts)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Target: mirror1.malwaredomains.com (justdomains)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Target: sysctl.org (hosts)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Target: zeustracker.abuse.ch (blocklist.php?download=domainblocklist)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Target: s3.amazonaws.com (simple_tracking.txt)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Target: s3.amazonaws.com (simple_ad.txt)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Target: hosts-file.net (ad_servers.txt)
  [i] Status: Pending...

  [✗] Status: Connection Refused
  [✗] List download failed: no cached list available
  [i] Consolidating blocklists...

  [✓] Consolidating blocklists
  [i] Extracting domains from blocklists...

  [✓] Extracting domains from blocklists
  [i] Number of domains being pulled in by gravity: 0
  [i] Removing duplicate domains...

  [✓] Removing duplicate domains
  [i] Number of unique domains trapped in the Event Horizon: 0
  [i] Number of blocklist source domains being added to the whitelist: 6...

  [i] Number of blocklist source domains being added to the whitelist: 6
  [i] Number of whitelisted domains: 6...

  [i] Number of whitelisted domains: 6
  [i] Parsing domains into hosts format...

  [✓] Parsing domains into hosts format
  [i] Cleaning up stray matter...

  [✓] Cleaning up stray matter
  [✗] dnsmasq: no process found
pihole-FTL: no process found
  [✓] DNS service is running
  [✓] Pi-hole blocking is Enabled
[cont-init.d] 50-gravity.sh: exited 0.
[cont-init.d] 99-tests.sh: executing... 
dnsmasq: syntax check OK.
[10-Feb-2018 09:01:33] NOTICE: configuration file /etc/php7/php-fpm.conf test is successful
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[cont-init.d] 99-tests.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
starting version 3.2.4
[services.d] done.

When it's "running" I start getting all kinds of connection errors in home-assistant.log like this...

2018-02-10 09:02:27 ERROR (SyncWorker_5) [homeassistant.components.sensor.darksky] Unable to connect to Dark Sky. HTTPSConnectionPool(host='api.darksky.net', port=443): Max retries exceeded with url: /forecast/cb6fe6ac0e42881a64ae49719334b90b/43.4692,-83.998863?units=us (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7268e5f0>: Failed to establish a new connection: [Errno -3] Try again',))
2018-02-10 09:02:48 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.entryway fails
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x6ed89b10>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='developer-api.nest.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x6ed89b10>: Failed to establish a new connection: [Errno -3] Try again',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 201, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 308, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/camera/nest.py", line 77, in update
    self._location = self.device.where
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 233, in where
    if self.where_id is not None:
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1230, in where_id
    return self._device['where_id']
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1023, in _device
    return self._devices[CAMERAS][self._serial]
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 200, in _devices
    return self._nest_api._devices
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1619, in _devices
    return self._status[DEVICES]
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1604, in _status
    value = self._get("/")
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1587, in _get
    return self._request('GET', path)
  File "/usr/lib/python3.6/site-packages/nest/nest.py", line 1565, in _request
    data=data)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 508, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='developer-api.nest.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x6ed89b10>: Failed to establish a new connection: [Errno -3] Try again',))
2018-02-10 09:02:49 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.basement_thermostat_nest_is_using_emergency_heat fails
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

Steps to reproduce

I started using Hass.io last weekend and this same thing started happening (triggered by a reboot), but I didn't track it down at the time. I reinstalled everything on the Raspberry Pi from scratch and then it started happening again after a reboot.

Anything I should be looking at to fix this problem? Need any more info?

nickmomrik commented 6 years ago

I set my router back to the default DNS, rebooted the Pi, and restarted Pi-hole. It loads properly and is able to update the blocklists. I reset DNS on the router to point to the Pi and ads start getting blocked again. If I reboot the Pi, it breaks again.

nickmomrik commented 6 years ago

Seems to be solved by setting the DNS servers in system-connections/resin-sample which is listed as optional in the Hass.io installation instructions. I would suggest mentioning this in the Pi-hole addon instructions.

Schiri commented 6 years ago

@nickmomrik Are you setting the DNS to localhost in this case in the resin-settings?

nickmomrik commented 6 years ago

No that's what you don't want. It needs to go outside to get it's DNS instead of trying to use itself. I'm pretty sure I used the Google DNS servers listed in those docs, which I also use in my Pi-hole config.

addons-assistant[bot] commented 6 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.