Devices wont stay connected, sometimes ipv4 local permission denied?

So I’m new to this and don’t understand a lot. But I wanted to sync photos/videos from my current phone back to my old pixel 2 phone (for the free storage upload to google photos which I’m sure many of you are aware of). I’m experiencing a couple problems that may or may not be related?

Fairly often the devices are “disconnected”. Sometimes they’ll reconnect for a bit but then disconnect again after a while. I haven’t been able to figure out what makes this happen. attached is a photo of the web GUI discovery failures

I noticed the ipv4 local discovery will jump back and forth between working and not working I think.

Also I noticed that when the devices are connected its been stuck at 80% synced on my current phone but on the pixel 2 it says its up to date? its been like that for days… dont know if it really hasnt finished or what. Also A “revert local changes” button popped up when this happened.

Again, sorry for my ignorance. let me know what other information you need from me to help solve this issue

Local discovery is broken in newer versions of Android. However, the devices should still be able to connect if you keep global discovery and/or relaying enabled (which they are by default). Have you by any chance tweaked the defaults and disabled any of the two options? Global discovery seems to be working though, judging by the screenshot. How about relaying?

I turned off Enable NAT Traversal, Global Discovery, and Enable Relaying once when i was trying to troubleshoot, but those settings are all on, on both phones and have been for a while, restarted phones and syncthing multiple times.

I’m new to this, how do I know if golbal discovery and relaying are working? Any other ideas on why the devices keep disconnecting and reconnecting randomly?

It should all be in the GUI. Please check the following under “This Device”:

The numbers are clickable and provide more information in a separate pop-up window.

oh right, like the screenshot I provided in my original post. discovery usually shows 2/5, sometimes 3/5 with the ipv4 local sometimes working and sometimes not. ipv6 local and global v6 are never working.

Listeners shows 3/3 when the devices show connected and working. Also shows 3/3 when the devices are disconnected.

I think maybe it disconnects when one of my phones goes to sleep? is that possible? what would I look for there?

I think it’s actually fine when it comes to discovery. Local discovery won’t work unless you run Syncthing as root.

Have you disabled battery optimisation for Syncthing in the Android settings? The app should ask for it on the first start, but I’d check it again just in case. Also, if you haven’t seen https://dontkillmyapp.com already, please do and follow the steps if your device/manufacturer is on the list.

What about the run conditions in the Syncthing app settings? Is it set to run both on Wi-Fi and mobile data? If only on Wi-Fi, maybe the phone is set to turn Wi-Fi off during sleep? Just throwing out some ideas here.

both phones say syncthing-fork battery usage is not optimized. One phone is a pixel 2 and the other is a pixel 6, I dont see them on the dontkillmyapp website.

I have it to run only on wi-fi on both phones. I tried to look for a wi-fi setting during sleep but couldnt find anything. One phone runs android 11 the other runs android 13

Yeah, you shouldn’t need to go through any of those hoops on Google phones.

When it comes to Wi-Fi sleep, apparently the setting has been removed in the newer versions of Android, but at the same time the current value is set to always keep Wi-Fi running, so theoretically this shouldn’t be the problem here.

You could, however, check whether the phones are actually available through Wi-Fi when the screen is off. You can do it in multiple ways, but a simple one would be to check which devices are connected to the router. You could also try to just ping them if you know their IP addresses or hostnames.

Also, please check the uptime as reported in the Syncthing Web GUI (which on Android is available through the left slide-out menu). This way, you will verify whether Syncthing has actually been running all that time, or whether it keeps being restarted when you turn on the screen.

I noticed that it disconnected again just now but it still had an uptime of ~8 hrs so the device being disconnected didnt reset the “uptime”… I did however grab a screenshot of maybe some errors on my remote device?

Heres another screenshot slightly different, while devices are “disconnected”

Let me try to explain what I think could be happening:

It seems like the two devices are behind the same NAT router, which blocks TCP traffic and apparently Syncthing didn’t get it to open the firewall via UPnP. But UDP (QUIC) did manage do punch through and now you have the same IP and port listed on the discovery server for both instances. The one in the screenshot above finds that address and starts a QUIC connection, but your router doesn’t send it to the other device, but back to the same instance. Therefore the “connected to self” message. It should work though in the other direction, unless the router starts associating the connection with the other device again, making Syncthing show disconnected. That would match the sometimes-working, then failing connections story.

To verify if that’s the situation, check your devices entries on the discovery server, like https://discovery.syncthing.net/?device=XXXXX-XXXXX-XXXXX-XXXXX

Enabling UPnP on your Internet router might help if possible, or check under Firewall Setup — Syncthing documentation.

again, sorry im a novice, a lot of what you said made no sense to me. how do you check device entries on the discovery server? and what am i looking for exactly? how do I fix my issue?

Also I did take a look at my router settings and UPnP is turned on.

Thank you so much for helping me and troubleshooting this issue!

Sorry for the late reply, and yeah the previous message was very technical. I thougt maybe someone else would pick up on it and see if that’s a plausible cause.

Besides turning on UPnP, you can check the entries on the discovery server by entering the URL I posted above in a browser. But you need to replace the XXXXX-XXXXX-XXXXX-XXXXX part by your real device ID, which you can find under Actions > Show ID in Syncthing’s Web GUI. So the address would look something like this:

https://discovery.syncthing.net/?device=S7UKX27-GI7ZTXS-GC6RKUA-7AJGZ44-C6NAYEB-HSKTJQK-KJHU2NO-CWV7EQW

Then check what server response is deplayed in the browser. You might want to redact it before posting here, like XX-ing out some numbers and your actual device ID.

no problem! Im just super thankful for people like you who take time to help troubleshoot issues for random people like me! Here’s what I get for each phone, i think when I did the first phone they showed as not being connected, and then by the time I did the second phone they were connected:

{“seen”:“2023-02-06T18:51:15.220XXXX83Z”,“addresses”:[“quic://73.XXX.XXX.4:22000”,“quic://73.XXX.XXX.4:22000”,“relay://104.XXX.225.XXX:2XXX7/?globalLimitBps=0\u0026id=XEWKRGO-XXXXXXX-FZCMXJM-XXXXXXX-IHYEW63-XXXXXXX-6O2CBFQ-CRLURAL\u0026networkTimeout=2m0s\u0026pingInterval=1m0s\u0026providedBy=Bytesize.org±+Seattle%2C+WA\u0026sessionLimitBps=0\u0026statusAddr=%3A22070”,“tcp://73.XXX.XXX.4:22000”,“tcp://73.XXX.XXX.4:22000”]}

{“seen”:“2023-02-06T22:32:13.504XXXX81Z”,“addresses”:[“quic://73.XXX.XXX.4:22000”,“quic://73.XXX.XXX.4:55502”,“tcp://73.XXX.XXX.4:22000”,“tcp://73.XXX.XXX.4:22000”]}

1 Like

Try formatting as code next time, makes it easier to read :wink:

I presume the 73.XXX.XXX.4 address is always the same, or are there slight differences? The doubled entries for quic:// and tcp:// do look strange otherwise. If the IP address and port for QUIC on both devices is the same, that’s the cause of your connection problems for sure. Now how did they get to list the same address / port?

Have you configured anything Syncthing-specific in your router’s firewall? Or just enabled UPnP?

yeah those 73.xxx.xxx.4 addresses are the same. Yup the quic addresses are the same on both phones except for the …4:55502 on the second phone, the others are all the same ending in 4:22000

FYI the second one is now showing:

{"seen":"2023-02-06T22:33:43.370998666Z","addresses":["quic://73.XXX.XXX.4:22000","quic://73.XXX.XXX.4:55502","relay://45.XX.XX.XXX:22067/?id=TVAXICF-XXXXXXX-BITFUF3-XXXXXXX-ZRFNM6O-XXXXXXX-N424GWJ-VPTEFA4\u0026networkTimeout=2m0s\u0026pingInterval=1m0s\u0026providedBy=Linode\u0026statusAddr=%3A22070","tcp://73.228.118.4:22000","tcp://73.228.118.4:22000"]}

Just FYI that relay ID portion (TVAXICF-XXXXXXX-BITFUF3-XXXXXXX-ZRFNM6O-XXXXXXX-N424GWJ-VPTEFA4) doesnt match the device ID’s I got from each phone… not sure if thats important or not

and no I havent configured anything syncthing specific on my router… i only checked to see that UPnP was enabled.

The relay ID not matching yours is fine. The one listed there is the ID of the relay server.

Maybe @calmh or @AudriusButkevicius have an explanation how several devices behind NAT can end up with the same IP address and port 22000 getting announced to global discovery, but one of them actually being reachable at that combination? I’m a bit clueless here.

IIRC if we listen on :22000 the discovery server will add one entry for the source IP and that port, for assisting in NAT punchthrough with manual port mappings. That’ll happen in addition to whatever UPnP/NAT-PMP/STUN port mapping might also be active.

1 Like

@calmh @acolomb so any idea how i might be able to solve this issue? I’m not really understanding the technical jargon.