As mentioned above by @sturpin, all Fly apps are connected via an internal Wireguard mesh network called 6PN. The 6PN IPv6 address and the hostname <app-name>.internal can be used to access other Fly apps under the same organization. If the hostname you used in the “broken” JDBC URL that caused connection errors was already the correct <app-name>.internal, then it could be a DNS configuration issue (try resolving DNS outside of Java / Sprint Boot?), or something Java / Spring Boot-specific (maybe it doesn’t like IPv6-only hostnames?).
You could also obtain a stable internal IP to access your PostgreSQL cluster with a Flycast address. You can read more about the tradeoffs, precautions to take, and private networking in general in our docs.