I try to emulate my Ionic application on Android. Once my application start in the emulated device, it breaks with the following error:
Application Error
net::ERR_CONNECTION_REFUSED (http://localhost:8100)
and also
Webpage not available
The webpage at http://localhost:8100 could not be loaded because: net::ERR_CONNECTION_REFUSED
Debugging same project works like a charm in browser and in iOS debugger.
cordova-plugin-whitelist is already installed and I have the following rule in my config.xml
<allow-navigation href="http://localhost*"/>
Any help would be appreciated.
I found the solution, I was running the command
ionic run android -c -s -l --address localhost
Removing --address localhost
from the command solve my problem means following command is ok
ionic run android -c -s -l
Quite funny, since adding that parameter, let me run my App in the iOS debugger respectively in case of iOS was a must.
You might want to try running
adb reverse tcp:8100 tcp:8100
Especially in case its a new device / emulator, so that port forwarding gets set up.
Using the following command solve the issue for me on ionic 5 with capacitor
ionic capacitor run android -l --address 0.0.0.0
The only solution I've got was to use my machine IP address instead of localhost for the API call
e.g.
NOK API endpoint: 'http://localhost:3002/api/'
OK API endpoint: 'http://192.168.1.XXX:3002/api/'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With