Unbound times out with: "communications error to 127.0.0.1#5335: timed out"

I am no expert.
If I was faced with this problem I would break it down into simple steps, testing at each stage. We know you are using a router with multiple WANs capable of load sharing in a country known for blocking popular web sites. A reliable VPN might be what you need.

I would start with the router with one WAN enabled, DHCP server enabled and using the ISP's DNS servers. Is internet access what is expected. Using https://www.dnsleaktest.com/ do I see the expected ISP's DNS server in the results.

Now change the routers DNS servers in DHCP to public DNS servers such as 8.8.4.4 Reconnect my client PC to the network and retest internet access and retest using https://www.dnsleaktest.com/ If the test shows anything other than the public DNS server then your ISP or government is redirecting your DNS queries.

If everything is good so far, install RPiOS on your Pi, run updates:
sudo apt-get update && sudo apt-get full-upgrade -y
Do you have good internet access on your pi. If so then install pihole and configure using a public DNS server. Manually set your DNS server on your client PC to use pihole. Does the web interface show the pihole is receiving requests and is blocking sites.
If it is good you now have a choice.

Either configure DHCP on your router adding only the Pis address as DNS server or disable the DHCP server on the router and enable it on the Pi but the Pi must have a static IP in the case where the router DHCP is disabled.
Only after you have passed this stage do you need to install and configure Unbound following unbound - Pi-hole documentation

1 Like