Ending “cleartext not permitted” — real HTTPS from phone to home server
One design change resolved an entire class of connection errors.
The problem
My phone companion app kept losing its link to my home server: “cleartext not permitted,” “no pairing data.” The app used plain HTTP and had the server's IP address baked in. Android blocks plain HTTP by default, and every address change meant a rebuild.
The fix
- Put each local service behind HTTPS on my private network, with a real certificate for the server's private name.
- Android always allows HTTPS, so there are no special rules, no IP baked into the app, and no rebuild when addresses change.
- Added a watchdog that health-checks the local services behind the HTTPS front, and set the services to start on boot.
Testing lesson
The certificate belongs to the name, not the IP. Testing by IP fails with a hostname mismatch even when everything is healthy. The right test pins the name to the IP so the certificate is still checked.
Takeaway
Fix the design, not the symptom.