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

**URL:** <https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148>\
**Category:** Help\
**Created:** [February 20, 2025, 2:12pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148 "2025-02-20T14:12:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 20, 2025, 2:12pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/1 "2025-02-20T14:12:49Z")

</div>

This is a fresh install on a new SD card.  
RPi4B/8GB,  
OS v12 (bookworm),  
Pi-Hole Core v6.0.1, FTL v6.0, WebUI v6.0 with Unbound/Wireguard enabled

## Expected Behaviour: No errors under diagnosis

## Actual Behaviour: CONNECTION\_ERROR under Pi-hole diagnosis

## Debug Token: [https://tricorder.pi-hole.net/1giz9GaN/](https://tricorder.pi-hole.net/1giz9GaN/)

---

<div class="post-metadata">

**Author:** ![rdwebdesign](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/rdwebdesign/32/51363_2.png) [@rdwebdesign](https://discourse.pi-hole.net/u/rdwebdesign)\
**Post date:** [February 20, 2025, 9:59pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/2 "2025-02-20T21:59:35Z")

</div>

This message was generated by the upstream server you are using (apparently Unbound). Pi-hole only logged what happened.

Maybe using a different upstream server will fix the issue.

---

<div class="post-metadata">

**Author:** ![bennor3814](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@bennor3814](https://discourse.pi-hole.net/u/bennor3814)\
**Post date:** [February 21, 2025, 12:06am UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/3 "2025-02-21T00:06:45Z")

</div>

Seeing the same error in the Pi-Hole Diagnostics, once yesterday and once today on a Pi 3+ running Pi-Hole v6 (updated from v5) and Unbound locally on the Pi 3B+. And saw the same error yesterday on a Pi Zero W also running Unbound locally that likewise was updated from Pi-Hole v5 to v6. From the Pi 3B+'s FTL.log file:

> 2025-02-20 15:09:20.302 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-20 15:24:45.742 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-20 15:25:15.606 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Connection prematurely closed by remote server)  
> 2025-02-20 15:26:32.622 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-20 15:47:19.982 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-20 15:48:29.742 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-20 16:11:47.502 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-20 16:14:44.142 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)

Checked the syslog file on the Pi 3B+ and don't see any error offhand around that same time.

Edit to add: Nothing has changed on the Raspberry Pi's other than updating Pi-Hole. Did not see, as far as I can remember, these kinds of errors in Pi-Hole v5 on either Pi device.

---

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 21, 2025, 11:44am UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/4 "2025-02-21T11:44:58Z")

</div>

I have repeated errors of this type along with some other errrors in between, but the vast majority is this "WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream"

The other errors that pop up in between are these:  
2025-02-20 23:15:56.464 INFO Flushing cache and re-reading config  
2025-02-20 23:15:56.466 INFO Blocking status is enabled  
2025-02-20 23:15:56.567 INFO Compiled 0 allow and 0 deny regex for 18 clients in 0.3 msec

...and several of these:  
2025-02-21 00:47:47.638 INFO Received 8/8 valid NTP replies from pool.ntp.org  
2025-02-21 00:47:47.638 INFO Time offset: 1.238286e-01 ms (excluded 0 outliers)

I am not sure if thse have any significance.

Updated debug token on: [https://tricorder.pi-hole.net/aYpRx5UK/](https://tricorder.pi-hole.net/aYpRx5UK/)

---

<div class="post-metadata">

**Author:** ![Angry\_Beaver](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/angry_beaver/32/45864_2.png) [@Angry\_Beaver](https://discourse.pi-hole.net/u/Angry_Beaver)\
**Post date:** [February 21, 2025, 2:04pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/5 "2025-02-21T14:04:47Z")

</div>

Good morning,

I am also having the same issues as others here. There have also been a couple of threads popping up for this in Reddit. So far, I do not think anyone has gotten an answer.

[https://tricorder.pi-hole.net/7TLfeLBG/](https://tricorder.pi-hole.net/7TLfeLBG/)

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/8/4/8408f270dcac49840244bda7469f26b1cd7233a3.png)

---

<div class="post-metadata">

**Author:** ![blackthroat](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/e68b1a/32.png) [@blackthroat](https://discourse.pi-hole.net/u/blackthroat)\
**Post date:** [February 21, 2025, 4:45pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/6 "2025-02-21T16:45:42Z")

</div>

Having same issue. Fresh install on RPI5 (4GB), bookworm, using unbound.

Core [v6.0.3]  
FTL [v6.0.1]  
Web interface [v6.0.1]

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/0/4/040935bcf2b45d357060ec0dca1cbed5832cb64f.png)

---

<div class="post-metadata">

**Author:** ![bennor3814](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@bennor3814](https://discourse.pi-hole.net/u/bennor3814)\
**Post date:** [February 21, 2025, 4:57pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/7 "2025-02-21T16:57:48Z")

</div>

From [a reddit discussion](https://www.reddit.com/r/pihole/comments/1ity4ul/diags_error_tcp_connection_failed_while_receiving/), it seems there might be [a fix in Unbound](https://github.com/NLnetLabs/unbound/issues/1237) by adding or increasing the value used for "incoming-num-tcp".

Added "incoming-num-tcp: 40" to the end of the Unbound configuration file "/etc/unbound/unbound.conf.d/pi-hole.conf" on my Raspberry Pi running Pi-Hole and Unbound (rebooted the Pi). Will keep an eye on Pi-Hole to see if this fixes the issue.

Edit to add: Initial fix didn't work. Got error almost immediately. Changing value to 50 and will monitor.

Edit 2: Trying 25 as the value to see if it does anything.

---

<div class="post-metadata">

**Author:** ![Angry\_Beaver](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/angry_beaver/32/45864_2.png) [@Angry\_Beaver](https://discourse.pi-hole.net/u/Angry_Beaver)\
**Post date:** [February 21, 2025, 7:07pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/8 "2025-02-21T19:07:02Z")

</div>

You might be referring to my post over there. Though I changed mine to 25 instead of 40.

Been going a little over 4 hrs without any errors. I also made a few more changes before this which did seem to help, but ultimately this is what seems to have solved it.

Now it might start throwing errors again when I make this post, but so far this has been the longest since V6 that I have gone without errors.

 ![image](https://discourse.pi-hole.net/uploads/default/original/3X/6/6/66182161fb83f875f2f00c19805c61ebe8574927.jpeg)

---

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 21, 2025, 7:47pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/9 "2025-02-21T19:47:15Z")

</div>

I did a pihole -up to latest releases [Core v6.0.3 FTL v6.0.1 Web interface v6.0.1] just shy of 5pm local and after reboot the errors disappeared from /var/log/pihole/FTL.log. It is now 9:46pm, so it is up for just about 5hrs without any occurences, so I assume something must been changed in the code.

---

<div class="post-metadata">

**Author:** ![bennor3814](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@bennor3814](https://discourse.pi-hole.net/u/bennor3814)\
**Post date:** [February 21, 2025, 8:05pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/10 "2025-02-21T20:05:36Z")

</div>

My Pi-Holes were updated to Core v6.0.3FTL v6.0.1Web interface v6.0.1 more than 8 hours ago and I was still getting the discussed Unbound connection error. After doing the "incoming-num-tcp" fix mentioned up page (and experimenting with the value) I have stopped receiving the error in he past two hours. Fingers crossed the error doesn't return.

---

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 21, 2025, 9:15pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/11 "2025-02-21T21:15:54Z")

</div>

The errors resurfaced 5-and-a-half hours post the aforementioned pihole update.  
Added the "incoming-num-tcp: 25" to the top of the Unbound configuration file "/etc/unbound/unbound.conf.d/pi-hole.conf" and will be monitoring

---

<div class="post-metadata">

**Author:** ![bennor3814](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@bennor3814](https://discourse.pi-hole.net/u/bennor3814)\
**Post date:** [February 21, 2025, 9:54pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/12 "2025-02-21T21:54:56Z")

</div>

With incoming-num-tcp: 25 still got an error on a Pi 3B+ running Pi-Hole + Unbound:

> 2025-02-21 16:47:24 CONNECTION\_ERROR Connection error ( **127.0.0.1#5335** ): TCP connection failed while receiving payload length from upstream ( **Resource temporarily unavailable** )

---

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 21, 2025, 10:15pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/13 "2025-02-21T22:15:10Z")

</div>

You mean putting 40 stopped the warnings?

---

<div class="post-metadata">

**Author:** ![bennor3814](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@bennor3814](https://discourse.pi-hole.net/u/bennor3814)\
**Post date:** [February 21, 2025, 10:38pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/14 "2025-02-21T22:38:20Z")

</div>

In my case, no. 40 did not stop the warning. Still got the error with the value at 25, 40 and 50 (with Unbound restarts in-between each value change) on a Pi 3B+ Pi-Hole Core v6.0.3FTL v6.0.1 Web interface v6.0.1 + Unbound. Trying 100 now (this time rebooted the Pi itself). In my case seems to go a few hours before the error appears when using the lower numbers.

**Edit to add:** Using 100 as the value didn't stop the warning.

> 2025-02-21 17:56:21 CONNECTION\_ERROR Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)

---

<div class="post-metadata">

**Author:** ![PatienceofStone](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/p/eb8c5e/32.png) [@PatienceofStone](https://discourse.pi-hole.net/u/PatienceofStone)\
**Post date:** [February 21, 2025, 10:44pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/15 "2025-02-21T22:44:56Z")

</div>

Maybe related? If it's not, I'll start a new topic.

In-place upgrade from v5 to v6.

Unbound is installed as my primary lan DNS and forwarder, but listening on an aliased lo0 address (127.0.1.2) -- along with the `8953` that I haven't figured out how to get rid of:

```auto
$ sudo netstat -nlp | grep 'unbound'
tcp 0 0 127.0.0.1:8953 0.0.0.0:* LISTEN 2613/unbound
tcp 0 0 127.0.1.2:53 0.0.0.0:* LISTEN 2613/unbound
tcp 0 0 127.0.1.2:53 0.0.0.0:* LISTEN 2613/unbound
tcp6 0 0 ::12:53 :::* LISTEN 2613/unbound
tcp6 0 0 ::12:53 :::* LISTEN 2613/unbound
tcp6 0 0 ::1:8953 :::* LISTEN 2613/unbound
udp 0 0 127.0.1.2:53 0.0.0.0:* 2613/unbound
udp 0 0 127.0.1.2:53 0.0.0.0:* 2613/unbound
udp6 0 0 ::12:53 :::* 2613/unbound
udp6 0 0 ::12:53 :::* 2613/unbound

```

`pihole.toml` has the correct setting for DNS upstreams:

```auto
  upstreams = [
    "127.0.1.2"
  ]

```

but the rDNS /PTR lookup function continues to "spam" the logs trying to resolve IP-to-Name on `127.0.0.1:53`:

```auto
2025-02-21 16:26:30.029 CST [1629/T1634] ERROR: Cannot receive UDP DNS reply: Timeout - no response from upstream DNS server
2025-02-21 16:26:30.029 CST [1629/T1634] INFO: Tried to resolve PTR "9.f.b.8.5.3.8.c.4.8.f.4.4.9.1.0.0.0.7.3.c.4.0.0.9.7.5.0.1.0.0.2.ip6.arpa" on 127.0.0.1#53 (UDP)

```

There's definitely nothing listening on port 53 for lo0:

```auto
$ sudo netstat -nlp | grep '127.0.0.1'
tcp 0 0 127.0.0.1:8953 0.0.0.0:* LISTEN 749/unbound
udp 0 0 127.0.0.1:123 0.0.0.0:* 998/ntpd

```

I haven't find anything in the distribution `.toml` or in the online docs that either require a separate rDNS resolver or let me set a custom rDNS server, maybe something "nondocumented"? Or that I need to use "legacy dnsmasq" to force?

---

<div class="post-metadata">

**Author:** ![Moritz\_Winklmann](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/moritz_winklmann/32/15540_2.png) [@Moritz\_Winklmann](https://discourse.pi-hole.net/u/Moritz_Winklmann)\
**Post date:** [February 22, 2025, 5:16am UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/16 "2025-02-22T05:16:54Z")

</div>

I get the same error message with DNSCrypt 2.1.7 without Unbound [Pi-Hole: Core v6.0.3, FTL v6.0.1, Web interface v6.0.1]

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

Only IPv6-servers with dnssec are entered in dnscrypt-proxy.toml.

---

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 22, 2025, 10:51am UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/17 "2025-02-22T10:51:45Z")

</div>

@bennor3814, I edited the setting to 40 after your remarks and rebooted. Pihole is running without errors since and have been roughly 12hrs. Fingers crossed.

---

<div class="post-metadata">

**Author:** ![bennor3814](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/b/a8b319/32.png) [@bennor3814](https://discourse.pi-hole.net/u/bennor3814)\
**Post date:** [February 22, 2025, 11:45am UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/18 "2025-02-22T11:45:56Z")

</div>

@panoshountis, Yes fingers crossed. Seems this is hit or miss on working. So far even increasing to 100 didn't work for me on one of my Pi's. I still get the error message. Like this one just a few minutes ago:

> 2025-02-22 06:38:48 CONNECTION\_ERROR Connection error ( **127.0.0.1#5335** ): TCP connection failed while receiving payload length from upstream ( **Resource temporarily unavailable** )

From the FTL.log:

> 2025-02-22 05:38:23.863 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-22 06:17:59.543 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-22 06:33:16.663 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-22 06:35:29.143 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)  
> 2025-02-22 06:38:48.183 WARNING Connection error (127.0.0.1#5335): TCP connection failed while receiving payload length from upstream (Resource temporarily unavailable)

I've tossed in the towel and have removed the "incoming-num-tcp" entry for now until there is a better fix available (if one is found). Obviously there is some sort of a change in Pi-Hole v6 that is now showing these errors when Pi-Hole v5 did not. Pi-Hole folks point the finger at Unbound and the "incoming-num-tcp" fix seems to be hit or miss on working (its a miss for me currently).

---

<div class="post-metadata">

**Author:** ![panoshountis](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/panoshountis/32/24917_2.png) [@panoshountis](https://discourse.pi-hole.net/u/panoshountis)\
**Post date:** [February 22, 2025, 7:21pm UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/19 "2025-02-22T19:21:18Z")

</div>

Got one single occurence, 20 odd hrs after setting "incoming-num-tcp: 40" and rebooting. Keeping an eye on it.

---

<div class="post-metadata">

**Author:** ![Jeremiah\_Van\_Offeren](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jeremiah_van_offeren/32/46084_2.png) [@Jeremiah\_Van\_Offeren](https://discourse.pi-hole.net/u/Jeremiah_Van_Offeren)\
**Post date:** [February 23, 2025, 12:51am UTC](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148/20 "2025-02-23T00:51:12Z")

</div>

setting "incoming-num-tcp: 25" seems to stop warning for me.

[Next page](https://discourse.pi-hole.net/t/connection-error-127-0-0-1-5335-tcp-connection-failed-while-receiving-payload-length-from-upstream-connection-prematurely-closed-by-remote-server/76148.md?page=2)
