net::ERR_CONNECTION_REFUSED (http://localhost:8080/)

I am facing this problem on a device with Android 6, that fix you mentioned you are using Ionic 4, right?
How about the android platform version? What is it?

Mine is 6.3.0 (not sure why).

It’s just a very simple project with Ionic 4, with a map only.

Can you post your “ionic info” output, and also describe the steps to get the error.

Sure Ii can,

Ionic Info:

Ionic:

   Ionic CLI                     : 5.2.2 (/Users/francisco/.npm-packages/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.2
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 7.1.0
   Cordova Platforms : android 6.3.0, browser 5.0.4, ios 5.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 5 other plugins)

Utility:

   cordova-res : 0.5.1 (update available: 0.6.0)
   native-run  : 0.2.7 (update available: 0.2.8)

System:

   Android SDK Tools : 26.1.1 (/Users/francisco/Library/Android/sdk)
   ios-deploy        : 2.0.0
   ios-sim           : 7.0.0
   NodeJS            : v8.11.3 (/usr/local/bin/node)
   npm               : 6.10.1
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001
> cordova plugin ls
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

Running on an Android device (just the same way I always did) in debug mode:
% ionic cordova run android -l -c --device --verbose --no-native-run

In my case it shows:
net::ERR_CONNECTION_REFUSED (http://localhost:8100/)

This is a very simple project in Ionic4, but I also have another one in Ionic3 that’s happening the same problem.

The device is a Samsung S5 with Android 6.0 (SM-G900M)

BTW, thanks for replying!

hi Sir @IonicGeoff i am getting Same problem in ionic4 if create any app.

Hmmm, sorry my experience is from a few months back and is probably no longer relevant. Try doing a Google search for whatever the error message is?

Thanks for your reply. ok.

Exactly! Can u solve it?

What do you want to know ? My workaround is to run your app with livereload.

I need that run without livereload

I have the same problem, i just update Angular 7 to 8.
Here are the versions that changed after update angular

my build was working fine until I added a --livereload flag, then when I build it without the flag “–livereload” I would get this error.

looking into my config.xml file, I found:

not sure how src=“undefined” got there, but that is what caused my issue.

changing it to src=“index.html” fixed the issue.

1 Like

I had this problem for days and all the solutions I found did not work.

Ionic recommends using Capacitor to build the app and not Cordova. With Cordova does not work, on the other hand with Capacitor it works fine.

In your app directory first delete the Android folder (if any) and the one in Platform / Android folder.

I used these commands in this order launched by Powershell while staying in the APP directory

ionic build

ionic capacitor add android

npx cap open android

The first command will create a www folder. If the last command give an error and does not open Android Studio, do it manually, (I recommend using 4.0 version). Open Android Studio → open folder, navigate to the folder named Android located in the folder in your APP and then it worked for me. In Android Sudio 4 make sure you have Gradle updated and the SDK loaded.

thanks very much, this fixed my problem

I just ran into this problem with capacitor.
Once I ran

$ npx cap open android --livereload

It added this to the capacitor.config.json:

"server: {
    "url": "http://localhost:8100",
    "cleartext": true
}

This was causing the same error as the cordova error and I was able to solve it by removing the previous block from capacitor.config.json

1 Like

Hey my friend I have a question about the connection with server with the method rest api basic authentication help me please.I am in the process of developing a mobile application using ionic and angular for the purpose of devloping a task so my problem is connecting with the server and accessing to the api
this is my issue in browser![Untitled|546x33]image


you can help me please

Do a search for CORS. This is a common problem, you will need to modify the server to allow access.

1 Like

the status to my request is 200 but the problem CORS still exist

Maybe this will help you?