Problem: The Cordova App when run on Android give a Connection refused error on https://localhost/* URLs.
Fix: Follow these steps:
- Edit package.json
- Set homepage from “./” to “https://10.0.2.2/”
- Save, build and run the App.
Probable Reason: Localhost seems to get routed to the host while the emulator runs the App within a virtual container (assumption).
10.0.2.2 is a special IP mapped to the “localhost” of the emulated environment.

Sreekumar (KJ) has been a hobby programmer from school days. Codemarvels is his personal blog from the year 2010, where he writes about technology, philosophy, society and a bit about physics.
He now runs a conversational AI company – DheeYantra – focusing his efforts to help businesses improve operational efficiency using digital employees powered by AI.
Leave a Reply