Before I clone the repo and check out the code, does anybody know if KDE Connect can pair with a device on 127.x.x.x?

Here’s why I’m asking (bear with me, it’s not super obvious):

I have a wifi AP that isn’t connected to the internet.

My PC (Linux) has its own 5G connection and is also connected to the wifi with no default route (there’s a bunch of smarthome stuff on that wifi that I address by IP directly).

My cellphone has its own 5G connection, and I’d like to connect the cellphone to the wifi also, so it can pair it with KDE Connect on my PC.

If I do, it works of course, but then the cellphone loses internet connectivity because Android won’t let me use the wifi without setting a default route to it (even though the Wifi AP’s DHCP doesn’t set a gateway and it shouldn’t…)

So instead, I figured I’d connect the cellphone to the PC with USB and reverse-forward the PC’s KDE Connect listening port so it appears locally on the cellphone at another port, by doing this on the PC:

adb reverse tcp:1717 tcp:1716

With this, the PC’s KDE Connect appears on localhost:1717 in the cellphone.

The problem is, when I go to Settings > Add devices by IP in the cellphone and add 127.0.0.1, it doesn’t see the PC’s KDE Connect. I hoped it would try all the ports on 127.0.0.1, filter itself out on port 1716 and find the PC’s KDE Connect on port 1717.

I also tried to add 127.0.0.1:1717 - i.e. specificy the port I want it to connect - but it doesn’t work either. I don’t think adding the port is even a valid syntax.

And finally I tried it the other way round, by forwarding the cellphone’s KDE Connect’s 1716 port on the PC at port 1717 with adb forward tcp:1717 tcp:1716 (and it totally works: I can telnet localhost:1717 on the PC and it connects) and tell the PC’s KDE Connect to add 127.0.0.1 as an explicit host by adding “customDevices=127.0.0.1” in the config file (see here) but that doesn’t work either.

Does anybody know if KDE Connect blacklists localhost to avoid pairing with itself by any chance? Or if it finds an instance of KDE Connect (itself or other) on a port, it won’t keep probing other ports? Is what I’m trying to do doable at all? 🙂