Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Connection prematurely closed by remote server)

I started having this problem after an "upgrade" from 5 to 6 a month or so ago.
After reading all the posts here, it looks like there's no fix, right? I see some have tried some config adjustments with mixed success.
When I get this same message, DNS is not working and my wife can't watch Biggest Loser. No name resolution
Connection error. 127.0.0.1#5335 TCP connection failed while receiving payload length from upstream (resource temporarily unavailable)
But then wait for an undetermined account of time, and it starts working again.

I got the error today for the first time

Connection error (2620:119:35::35#53): TCP connection failed while receiving payload length from upstream (Connection reset by peer)

I have several interupted connection per day. Press F5 in the pi-hole Dashboard helps most times

I have been experiencing these errors since Feb 20 2025 that I upgraded to a freshly installed PiHole v6 and initiated this thread. I have tried several configuration tweaks over the past weeks without any tanglible resolution of the perceived problem. I keep on noticing anywhere from zero to a handful occurences per day but these connection lapses never really manifested themselves to be a real problem. My network is predominantly a SOHO setup.

I get this error about once a week still after increasing unbound 's incoming-num-tcp over its default of 10.

2025-05-01 14:43:12 CONNECTION_ERROR Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Connection prematurely closed by remote server)

https://tricorder.pi-hole.net/72UMC4Vx/

Once a week isn't problematic - just another wrinkle to iron out. Hope all the info is helping. Cheers and thanks for all the hard work you guys/gals put into this project.

I have just recently started to get this error. I use my pihole as my DHCP server. When this error occurs it cripples my internet and only allows pages cached pages to function (barely). It essentially makes all webpages unreachable. This is obviously a problem and often have to switch back to my service provider for DHCP which is of course not what I prefer.

The error is as follows:

CONNECTION_ERROR Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Connection prematurely closed by remote server)

https://tricorder.pi-hole.net/pgsmognt/

This error is making the pihole unusable and it needs to be fixed. This never happened with the v5.

Edit: Nothing in this thread as resolved the issue for me

Edit 2: I have seen some people say that this happens when visiting a specific website. I have a lot of clients and I am trying to narrow down what it could be but in the meantime if anyone finds websites which seem to trigger this can they please let the thread know!

Edit 3: I have done some testing and it doesn't seem to be a particular website. It just keeps going to Servfail and then coming back. It's been happening for over half and hour now. Madding.

Hi,
The "issue" was logged at the Unbound forum failed to send TCP(read_write) packet (Connection prematurely closed by remote server) · Issue #1237 · NLnetLabs/unbound · GitHub
However, after lots of contributions to the post it was closed with:

Thanks everyone for the discussion and data points!
I am going to close the issue to avoid future confusion for users stumbling on this.
The summary is that this is not an Unbound issue. The "issue" is extra harmless logging on pihole v6.
Any configuration change proposals discussed here were useful only to try and pinpoint what was happening.
No configuration change can "solve" the "issue".

I am currently having the below settings on my the instances of Pi-hole v6, where I have some 40 clients on one of them. I see the "issue" intermitted 5 to 10 times daily. I have no longer "debug.queries" enabled.
It might change if incoming-num-tcp: is increased to a higher value, I just settled with 50.

incoming-num-tcp: 50
tcp-idle-timeout: 1024
outgoing-range: 8192
num-queries-per-thread: 4096

Steen

3 Likes

I'm still suffering from getting this error every day and I can't believe no one can solve this issue
I even ask chatgpt to help me, but the reply was "sorry no one till now solve this issue"

All the solutions and suggestions written here are nothing but personal efforts and are not based on sound foundations. Therefore, Pihole and Unbound must seriously and quickly reconsider in order to find final solutions that will end this problem and this discussion.

Connection error (**127.0.0.1#5335** ): TCP connection failed while receiving payload length from upstream (**Connection prematurely closed by remote server** )
yep, same here, after an inplace v5 -> v6 upgrade. I am using the unbound config as seen in Pi Hole Docs -> Unbound.
When the issue happens once, it kinda isn't noticeable. However I had it happen for 5 Mins straight, and there was no DNS resolution for those 5 mins because of the unbound connection resetting issue.
This worked flawless under v5 (or wasn't logged at all)

2 posts were split to a new topic: CNAMEs do not resolve correctly

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.