OCI containers (go apps) not being able to use DNS resolution to find other containers randomly

I strongly suspect this issue is User caused (me). But for the life of me I haven’t been able to figure out if the solution I am using is the correct one

I have Incus hosted on an OVH vps, I have experienced the same issue in two different OCI app containers (Memos and Vikunja) where trying to connect to a third Postgresql database through DNS resolution fails with a very similar error message:

time=2026-08-11T19:15:11.173Z level=ERROR msg="Could not connect to db: dial tcp: lookup postgres.incus on [::1]:53: read udp [::1]:58328->[::1]:53: read: connection refused"

At first I thought this was an issue with the container(s), but if I try starting the container it will randomly work sometimes. I ended up with the idea that the resolv.conf file generated inside the containers sometimes does not import the correct values, so I am using the following to hardcode the correct dns namserver:

incus config set <container> oci.dns.nameservers <Incus Bridge IP>
incus restart <container>

However, sometimes this still does not work on some containers, they will still fail to access the network.

dial udp <Incus Bridge IP>:53: connect: network is unreachable

My question is, is this the correct way to set things up?, for some reason I am overthinking it and not sure if I am doing things right. This is as far as I have been able to identify a Golang issue exclusively, I have tested other types of OCI app containers, and none of them have had this issue.

After taking a deeper look, it seems that the OCI entrypoint that starts the program immediately is for some reason causing an issue where the DNS is not yet enabled on the container, and failing before it can be added.

I corrected this by adding a sleep before the container runs the application and this seems to have fixed all of the issues. seems like a workaround more than an official fix, but it is what it is.

That is true until around 7.2 or 7.3 where they got a 5 sec timeout to wait for IP’s to be ready.

That makes a lot of sense, I am on 7 LTS. for some reason thought this issue wasn’t incus related. good to know I am not going crazy