1

I get "Application Error net::ERR_CONNECTION_REFUSED (http://localhost/) when trying to run an app on an Android 8 actual device. It was compiled on Ionic Framework Ionic, Release type.

I've tried everything I can find on the Internet. Anybody have any other ideas?

Ionic:

   Ionic CLI          : 5.1.0 (C:\Users\me\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.8
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : not installed
   Cordova Platforms : none
   Cordova Plugins   : cordova-plugin-ionic 4.1.7, cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 15 other plugins)

Utility:

   cordova-res : 0.3.0
   native-run  : 0.2.6

System:

   NodeJS : v8.10.0 (c:\Program Files\nodejs\node.exe)
   npm    : 6.11.3
   OS     : Windows 10

These are my package.json dependencies:

  "dependencies": {
    "@angular/animations": "~7.2.15",
    "@angular/common": "~7.2.15",
    "@angular/compiler": "~7.2.15",
    "@angular/compiler-cli": "~7.2.15",
    "@angular/core": "~7.2.15",
    "@angular/forms": "~7.2.15",
    "@angular/http": "~7.2.15",
    "@angular/platform-browser": "~7.2.15",
    "@angular/platform-browser-dynamic": "~7.2.15",
    "@ionic-native/background-mode": "5.14.0",
    "@ionic-native/badge": "^5.14.0",
    "@ionic-native/browser-tab": "5.14.0",
    "@ionic-native/calendar": "5.14.0",
    "@ionic-native/core": "^5.14.0",
    "@ionic-native/http": "5.14.0",
    "@ionic-native/in-app-browser": "5.14.0",
    "@ionic-native/network": "5.14.0",
    "@ionic-native/onesignal": "5.14.0",
    "@ionic-native/pro": "5.14.0",
    "@ionic-native/splash-screen": "5.14.0",
    "@ionic-native/status-bar": "5.14.0",
    "@ionic/pro": "^2.0.4",
    "@ionic/storage": "2.2.0",
    "@reactivex/rxjs": "6.5.3",
    "@vimeo/player": "2.10.0",
    "android-versions": "1.5.0",
    "cordova-android": "^7.0.0",
    "cordova-ios": "5.0.1",
    "cordova-plugin-add-swift-support": "2.0.2",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-browsertab": "0.2.0",
    "cordova-plugin-calendar": "5.1.4",
    "cordova-plugin-compat": "1.2.0",
    "cordova-plugin-device": "2.0.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-inappbrowser": "3.1.0",
    "cordova-plugin-ionic": "^5.4.4",
    "cordova-plugin-ionic-keyboard": "2.2.0",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-splashscreen": "^5.0.3",
    "cordova-plugin-statusbar": "2.4.3",
    "cordova-plugin-whitelist": "1.3.4",
    "if-env": "^1.0.4",
    "ionic-angular": "3.9.8",
    "ionicons": "4.6.3",
    "npm-gui": "^2.1.0",
    "npm-install-peers": "^1.2.1",
    "onesignal-cordova-plugin": "^2.6.0",
    "promise-polyfill": "^8.1.3",
    "rxjs": "^6.5.3",
    "rxjs-compat": "^6.5.3",
    "sw-toolbox": "3.6.0",
    "zone.js": "^0.8.29"
  },
Magmatic
  • 1,754
  • 3
  • 19
  • 34

4 Answers4

0

You get that error because the data is not on your device. It can not access localhost on your android's device because there's none. The best you can do is o run it on an emulator on your computer. There you can use the localhost. Check How to solve Error Code: 0, Message HTTP failure on android - IONIC API, and see if it helps you. If you have any doubts about configuring it, feel free to ask.

jcmendes98
  • 148
  • 1
  • 10
  • Thanks, but I compiled the app in Ionic Framework, successfully. It should be a fully working app. How can you say there is no data on my device after I installed the app? – Magmatic Oct 07 '19 at 14:26
0

You can run your app. Just connect your device with your computer using USB cable then open chrome and inspect element. Click on three dots in the right corner (Customize and control devTools). Then choose More Tools>Remote devices. You can see your device there. Add your server port like the attached. Open chrome in your mobile and enter server url and go like http://localhost:3000. Now you can open your android app and server is accessible.

enter image description here

aman
  • 125
  • 1
  • 11
  • Thanks. I looked into that, and it's really cool, but I'm not trying to debug my app or just develop on my phone. I'm trying to create an actual app for my phone and when I try to run it I get this error. – Magmatic Oct 07 '19 at 15:00
0

I fixed the problem by doing the following replacement in my config.xml file:

- <content src="index.html?env=app-phonegap" />
+ <content src="index.html" />
Finesse
  • 9,793
  • 7
  • 62
  • 92
0

Simply update the webview plugin and and do clean installation of the platform and plugin files again. Follow the steps detailed in this answer

Evan MJ
  • 1,967
  • 13
  • 16