Could not contact DNS servers coming and going after restarts

I run a simple network at home, just 10.0.0.x

DNS: 8.8.8.8 directly. All cabled.

A ubuntu server 24.04:

network:
  version: 2
  ethernets:
    enp4s0:
      dhcp4: no
      addresses: ["10.0.0.183/24"]
      gateway4: 10.0.0.1
      nameservers:
        search: ["mos-eisley.dk"]
        addresses:
          - "8.8.8.8"
          - "8.8.4.4"

With Home Assistant Core in a docker:

services:
  home-assistant:
    container_name: home-assistant
    restart: unless-stopped
    network_mode: host
    image: homeassistant/home-assistant:2026.2.2
    volumes:
      - /run/dbus:/run/dbus:ro
      - /etc/localtime:/etc/localtime:ro
      - /opt/homeassistant:/config
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
    ports:
      - 8123:8123
    environment:
      - TZ=Europe/Copenhagen
    privileged: true
    dns:
      - 8.8.8.8

After updating integrations, I started seeing "Could not contact DNS servers " in the logs:

Then I upgraded 2 integrations:

oot@sparrow:/opt/homeassistant/custom_components# ls -lt | more

total 144

drwxr-xr-x 4 root root 4096 Mar 7 08:50 cardata
drwxr-xr-x 6 root root 4096 Mar 7 08:49 entity_manager

and restarted Home Assistant - through “Repair”

Then the messages disappeared complely until this morning after Integrations update:

drwxr-xr-x 8 root root 4096 Mar 11 07:30 energidataservice
drwxr-xr-x 4 root root 4096 Mar 11 07:29 ics_calendar

And they are back:

I have pretty much ruled out network and Ubuntu now, It for sure seems that restart of Home Assistent causes this go start - or disappear.

Heres a log sample:

2026-03-11 09:45:35.731 ERROR (MainThread) [homeassistant.components.google.coordinator] Error fetching [email protected] data: Error communicating with API: Error connecting to API: Cannot connect to host www.googleapis.com:443 ssl:default [Could not contact DNS servers]
2026-03-11 09:45:35.770 ERROR (MainThread) [homeassistant.components.spotify] Error requesting Normann P. Nielsen Devices data: Cannot connect to host api.spotify.com:443 ssl:default [Could not contact DNS servers]
2026-03-11 09:45:35.776 ERROR (MainThread) [homeassistant.components.spotify.coordinator] Error requesting spotify data: Cannot connect to host api.spotify.com:443 ssl:default [Could not contact DNS servers]
2026-03-11 09:45:35.867 ERROR (MainThread) [homeassistant.components.google.coordinator] Error fetching Normann (gmail) data: Error communicating with API: Error connecting to API: Cannot connect to host www.googleapis.com:443 ssl:default [Could not contact DNS servers]
2026-03-11 09:45:36.943 ERROR (MainThread) [homeassistant.components.google.coordinator] Error fetching Helligdage i danmark data: Error communicating with API: Error connecting to API: Cannot connect to host www.googleapis.com:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.ring.com:443 ssl:default [Could not contact DNS servers]
ring_doorbell.exceptions.RingError: aiohttp Client error during query of url https://api.ring.com/clients_api/dings/************/share/play: Cannot connect to host api.ring.com:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.ring.com:443 ssl:default [Could not contact DNS servers]
ring_doorbell.exceptions.RingError: aiohttp Client error during query of url https://api.ring.com/clients_api/dings/************/share/play: Cannot connect to host api.ring.com:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
aiodns.error.DNSError: (11, 'Could not contact DNS servers')
OSError: [Errno None] Could not contact DNS servers
    raise ClientConnectorDNSError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorDNSError: Cannot connect to host api.connectedcars.io:443 ssl:default [Could not contact DNS servers]
2026-03-11 10:31:35.777 ERROR (MainThread) [homeassistant.components.spotify.coordinator] Error requesting spotify data: Cannot connect to host api.spotify.com:443 ssl:default [Could not contact DNS servers]

So its in “bulks” - the errors comes in…

What’s this look like?

docker exec home-assistant cat /etc/resolv.conf
docker exec home-assistant nslookup google.com
docker exec home-assistant nslookup google.com 8.8.8.8

Note that ports is unneccessary with host networking and the recommended image comes from ghcr.io. See docs. devices is not needed with privileged either. I’d also recommend to use the same container name as in the docs.

Hi,

Thanks for the response - I am aware of the details You are writing about :slight_smile:

I have had endless pings and stuff running in the docker instance without issues… but here goes:

root@sparrow:/home/bnp# docker exec home-assistant cat /etc/resolv.conf
# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 8.8.8.8
search mos-eisley.dk
options edns0 trust-ad

# Based on host file: '/etc/resolv.conf'
# Overrides: [nameservers]
root@sparrow:/home/bnp# 

root@sparrow:/home/bnp# docker exec home-assistant nslookup google.com
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
Name:	google.com
Address: 192.178.25.110
Name:	google.com
Address: 2a00:1450:4003:810::200e

root@sparrow:/home/bnp# 

root@sparrow:/home/bnp# docker exec home-assistant nslookup google.com 8.8.8.8
;; UDP setup with 8.8.8.8#53(8.8.8.8) for google.com failed: permission denied.
;; no servers could be reached
;; UDP setup with 8.8.8.8#53(8.8.8.8) for google.com failed: permission denied.
;; no servers could be reached
;; UDP setup with 8.8.8.8#53(8.8.8.8) for google.com failed: permission denied.
;; no servers could be reached

root@sparrow:/home/bnp# docker exec home-assistant nslookup google.com 8.8.8.8
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
Name:	google.com
Address: 192.178.25.110
Name:	google.com
Address: 2a00:1450:4003:810::200e

root@sparrow:/home/bnp# 

the errors in the last is interesting., running it several times gives both success and failures…

Its a pretty standard ubuntu and I have not found any iptables block on udp:53 or similar

As stated - 2 things are wierd:

  1. It comes in spikes - not a constant error rate
  2. I have seen 2 times that a Home Assistant restart changed the situation completely - like 2 days without a single error, and now after morning restart - spikes again

I am at the same kernal as mentioned here: Unstable network connection from inside Home Assistant Docker Container - #6 by maks

Hmm. Can you try with another DNS Server?

docker exec home-assistant nslookup google.com 1.1.1.1
docker exec home-assistant nslookup google.com 9.9.9.9

Just out of curiosity, does this mention e1000e?

ls -l /sys/class/net/*/device/driver

Anything interesting in the kernel logs?

journalctl -kr

Also try to add this to the compose and up again

cap_add:
  - NET_RAW

Perhaps also disable UFW if enabled

ufw disable
root@sparrow:/home/bnp# ufw status
Status: inactive
root@sparrow:/home/bnp#
root@sparrow:/home/bnp# ls -l /sys/class/net/*/device/driver
lrwxrwxrwx 1 root root 0 Feb 21 17:21 **/sys/class/net/enp4s0/device/driver** -> **../../../../bus/pci/drivers/tg3**
root@sparrow:/home/bnp#

root@sparrow:/home/bnp# docker exec home-assistant nslookup google.com 1.1.1.1
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: google.com
Address: 142.250.147.102
Name: google.com
Address: 142.250.147.113
Name: google.com
Address: 142.250.147.100
Name: google.com
Address: 142.250.147.101
Name: google.com
Address: 142.250.147.138
Name: google.com
Address: 142.250.147.139
Name: google.com
Address: 2a00:1450:4025:c01::66
Name: google.com
Address: 2a00:1450:4025:c01::65
Name: google.com
Address: 2a00:1450:4025:c01::8b
Name: google.com
Address: 2a00:1450:4025:c01::8a

root@sparrow:/home/bnp# docker exec home-assistant nslookup google.com 9.9.9.9
Server: 9.9.9.9
Address: 9.9.9.9#53
Non-authoritative answer:
Name: google.com
Address: 142.251.142.46
Name: google.com
Address: 2a00:1450:4005:804::200e
root@sparrow:/home/bnp#

And no DNS errors since yesterday around 21:00

Just for Info - after moving to another kernel: