mirror of
https://github.com/fosrl/newt.git
synced 2026-07-15 21:16:40 -05:00
[GH-ISSUE #284] Newt loses connection to server and will only reconnect on service restart #5855
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @imoBooze on GitHub (Mar 28, 2026).
Original GitHub issue: https://github.com/fosrl/newt/issues/284
Originally assigned to: @oschwartz10612 on GitHub.
Describe the Bug
Whenever the wifi of a site disconnects for a period of time then reconnects, the newt of the site is unable to reconnect to pangolin. The logs of newt mentions several periodic ping failures.
Environment
To Reproduce
Expected Behavior
Newt reconnects after wifi outage.
@github-actions[bot] commented on GitHub (Apr 12, 2026):
This issue has been automatically marked as stale due to 14 days of inactivity. It will be closed in 14 days if no further activity occurs.
@imoBooze commented on GitHub (Apr 12, 2026):
As of newt version 1.11.0, this issue appears to have been fixed. Could others also confirm?
@Jdsx74 commented on GitHub (Apr 16, 2026):
I have the same problem with Pangolin 1.17.0 and Newt 1.11.0.
I start Newt service, but after 4/5 days the connection drop and i have to restart the newt service to be able to access to site again..
Thank you !
@Kornelius777 commented on GitHub (Apr 17, 2026):
Same here.
Would it be possible to implement a health check so that a script could reboot the newt server?
@svillar commented on GitHub (Apr 18, 2026):
I've newt 1.11.0 and I can easily reproduce this issue. Not following the same steps. In my case newt is runnning in a docker container in a NAS (ARM) which is connected via ethernet, so unless something very wrong happens it's always online. At some point it disconnects:
and then it never recovers (when I got the log it was reporting >1000 consecutive failures). Only restarting it makes it work again. It's a serious issue as it makes resources lose all connectivity
@svillar commented on GitHub (Apr 18, 2026):
I'm BTW available for further testing, using an image with extra debugging or the like, just ping me back.
@AstralDestiny commented on GitHub (Apr 18, 2026):
@svillar Mind poking me on discord and throw me a site config?
@v3rm1n0 commented on GitHub (Apr 24, 2026):
Same issue here. My router restarts frequently for updates, resulting in exactly this. Would be possible to have newt exit or kill itself after x consecutive failures? That way systemds restart on failure could work
Edit: I am on newt 1.11.0
@sandroshu commented on GitHub (Apr 24, 2026):
It is not resolved in the latest available release.
Workaround still works for systemd service but not optimal mentioned in my issue for the time being. https://github.com/fosrl/newt/issues/310
Create a service for it or run it in a screen session in the background. For eg. I have a separate service newt-healer:
@AstralDestiny commented on GitHub (Apr 24, 2026):
Wouldn't really use the latest RC right now honestly, We've got a few critical bugs.
@Wireheadbe commented on GitHub (Apr 27, 2026):
I had tried to work around this by using the "healthy" file, but Newt apparently doesn't remove that file when its status is unhealthy... that could simply be fixed in code when a connectivity issue exists, that /var/healthy gets removed.
At that point, the container would restart, and that's that.
@bajo commented on GitHub (Apr 29, 2026):
Thanks @sandroshu for pointing me to this issue.
Copying my comment from the closed ticket here, maybe it is useful for somebody else in here. :)
I faced a similar problem when my cheap VPS ran out of memory and OOM killer did its job on pangolin. After the service restarted, newt failed to automatically reconnect. That is on newt version 1.10.4 on NixOS.
Thus, I added a simple systemd watchdog service and timer on the host on which newt is running.
and
The
--resolve your-app.example.com:443:1.2.3.4part is only useful for me because I'm using the same fqdn internally as I do on the public Internet, so I need to make sure curl actually checks the app in the Internet and not on my LAN.@jdeluyck commented on GitHub (May 7, 2026):
I have newt running both in containers and native on the OS. While I can easily hook into the native ones logs, the containerised version runs on Home Assistant and I have less flexibility there.
I've experienced this too frequently - I just updated my opnsense router and this resulted in my newt tunnels going down and not re-establishing.
@dephekt commented on GitHub (May 7, 2026):
I am testing a patch to newt that causes it to recover properly when the connection is available again rather than continuing to log the tunnel is down forever. I will make a PR in a week after I test it more extensively in my local production environment.
This reflects the state I find Newt in when the issue happens. There's a connection loss between my home and VPS which kills the websocket (control plane) and wireguard tunnel (data plane). Eventually the connection issue clears, and Newt reestablishes the control plane but leaves the data plane in a dead state without recovering it. So my downstream containers are not getting requests from the edge.
To reproduce it, I can firewall the UDP link for several minutes, then unblock it. Newt won't bring that WG tunnel back up even though it has a working control plane. Then with my patches, it does recover the tunnel.
Log signature with my proposed fixes:
Branch here for anyone curious. Diff link vs. upstream main here. The commit messages go into deeper technical detail.
I think it happens for two reasons which layer, i.e. fixing the first requires the second fix, from my testing. Otherwise the hardcoded attempt cap on
SendMessageIntervalprevents the recovery (see more below).First, the recovery trigger in
startPingCheckis gated bycurrentInterval < maxInterval, which becomes permanently false after the defaultpingIntervalwas bumped from 3s to 15s while leavingmaxInterval=6s. So the recovery branch never executes under default settings; which is why we see the failure counter just climbing forever in the logs from everyone's reports (mine too).Second, even when recovery does fire (e.g. set
PING_INTERVAL=3) theSendMessageIntervalit uses to keep pumpingnewt/ping/requestover the websocket has a hardcoded 10-attempt cap, so the goroutine exits silent after ~27 seconds. If Pangolin'snewt/ping/exitNodesreply gets delayed past that window, the recovery loop dies and theconnectionLostgate prevents any further attempts (until the container is restarted).@oschwartz10612 commented on GitHub (May 7, 2026):
I think your analysis is correct @dephekt and your code changes seem reasonable. If you would be interested in opening a PR I can test further and then merge for a release shortly.
@oschwartz10612 commented on GitHub (May 8, 2026):
Actually I think your changes with
shouldFireRecoveryincommon.goare good but I dont think we can change the SendMessageInterval function to not have the timeout. I originally added the timeout to prevent the server from getting hammered by many different newts all stuck in some sort of requesting loop if there was any sort of bug that caused it to never cancel. I think I will look for a new solution to that bug, but I took your commit for fix the recovery issue. I will fix the interval thing and do a release shortly. Thanks so much for your help! :}@oschwartz10612 commented on GitHub (May 8, 2026):
In
901ec71bafI bumped up the max attempts and in663e98af60I made a change to not consider a send an attempt when the websocket is disconnected. This way if the websocket is disconnected it will keep sending until its back online when it will start sending again.@dephekt commented on GitHub (May 8, 2026):
That makes sense. I clearly hadn't thought about it from your perspective as an operator at scale. Glad I could help; this one bites me once a month and I only just recently had time to dig into it 😅 I'm sure you know the feeling!
@Jason-Keller commented on GitHub (Jun 5, 2026):
Hello. I apologize if this is not the right place for my question, but I seem to have some of the same issues as @imoBooze in regards to connecting Newt to a host. I'm getting a 403 denied error in Newt (Docker container in Unraid). This worked for a time, until I tried to integrate Cloudflare's proxies into the mix. I got it to work for a bit, but now I get 403 errors.
Some environment details:
3.7.3(used to be:latest, but I wanted to try something)Here is a bit of the Unraid Docker container logs for Newt (sorry about formatting):
Additionally, here are my Traefik logs as a result of
sudo docker compose logs -f traefik:A few steps I've undergone to troubleshoot:
config/crowdsec/config.yamlIn the End
I hope someone can help. I am happy to file a separate report if needed, and I can provide any info or sanitized configs you might need.
Thank you in advance very much! Loving Pangolin, and I feel like I'm close to solving this haha.