net::ERR_CONNECTION_REFUSED when building with android studio

I get that message when building the debug apk with Android Studio. Seems that the app is still trying to build referencing localhost:8100. Steps to reproduce:

  • npm run build
  • npx cap copy android
  • npx cap open android
  • Hit the Build Apk on Android Studio

Here is my capacitor.config.json

{
  "appId": "io.ionic.starter",
  "appName": "iaire",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www",
  "cordova": {},
  "server": {
    "url": "http://localhost:8100",
    "cleartext": true,
    "allowNavigation":[
      "localhost:8100/*"
    ]
  }
}

I also have to say that i have used live-reload feature before.

1 Like

Did you discover the solution? I had an older tablet working with this, but then trying a new tablet it does not work.

that makes the capacitor app to try to load from the live reload server, but if the live reload server is not running then it won’t be able to load.
When not using the live reload server you have to remove the server url entry from capacitor.config.json

1 Like