Skip to content Skip to sidebar Skip to footer

Ionic 4 Net::ERR_CONNECTION_REFUSED(http://localhost/)

I'm facing a problem that when I try to create mobile Front-End application based on Ionic 4 but a net:ERR_CONNECTION_REFUSED(http://localhost/) show up when I run it with cordova

Solution 1:

For anyone else losing their mind that might be using Capacitor go into your capacitor.config.json file and remove this:

"server": {
    "url": "http://localhost:8100"
}

I've had this in my config file for sometime and only just now started causing issues so I'm not sure if a new Capacitor patch has changed this behavior on prod builds or what but this resolved my issue. God speed to the rest of you.


Solution 2:

You can try to use this

ionic capacitor run <platform> [options]

ionic capacitor run android -l --external

--external can help to use the app on external devices on the same network. just try it...

ionic capacitor run
ionic capacitor run android
ionic capacitor run android -l
ionic capacitor run ios --livereload
ionic capacitor run ios --livereload-url=http://localhost:8100

I found this on capacitor docs ionic capacitor run


Solution 3:

20-09-2020: For Capacitor apps

This didn't work for me: I don't know why.

ionic cap run android -l --external

But this works:

ionic cap run android -l --host=0.0.0.0

Solution 4:

I have this versions:

"@capacitor/android": "^2.4.3",
"@capacitor/cli": "^2.4.3",
"@capacitor/core": "^2.4.3"

And im changed capacitor.config.json file:

Add this:

"server": {
    "cleartext": true
  }

And turn false "bundledWebRuntime"

And it worked!


Post a Comment for "Ionic 4 Net::ERR_CONNECTION_REFUSED(http://localhost/)"