Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 on android studio emulator. This what i m using

Angular CLI: 7.1.4
Node: 8.9.4
OS: win32 x64
Ionic version   4.5.0

My config.xml

config.xml

like image 952
Redouan Ait El-mkdem Avatar asked Feb 04 '19 22:02

Redouan Ait El-mkdem


2 Answers

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

like image 67
hectorromerodev Avatar answered Oct 23 '22 05:10

hectorromerodev


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.

like image 33
Aaron Jordan Avatar answered Oct 23 '22 06:10

Aaron Jordan