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 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

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!