Ionic application: Able to run on browser but not working on Ionic DevApp

I’m new to ionic, please forgive me if my question is stupid.
During the development, I’m using the browser to show and test my application which everything is working perfectly without any issue, but when I test my application on the Ionic DevApp in my android device, the application not able to communicate with the backend. Every time I send a request (such as login details), the system will response [object progressevent].
The error that display through console log:

[ng] [console.log]: {
[ng]   "headers": {
[ng]     "normalizedNames": {},
[ng]     "lazyUpdate": null,
[ng]     "headers": {}
[ng]   },
[ng]   "status": 0,
[ng]   "statusText": "Unknown Error",
[ng]   "url": "http://localhost:8080/restapi/api/user/login",
[ng]   "ok": false,
[ng]   "name": "HttpErrorResponse",
[ng]   "message": "Http failure response for http://localhost:8080/restapi/api/user/login: 0 Unknown Error",
[ng]   "error": {
[ng]     "isTrusted": true
[ng]   }
[ng] }

I have search and try to find solution on different online resources, but unfortunately the solutions provided by others is not working in my scenario. Thus, I’m posting this question to request for help from any of you who are expert in ionic.
Thank you,

My application:
Frontend: Ionic + Angular
Backend (REST API): Java Spring MVC, Oracle Developer Database, Hibernate

One of the request code(Login Function & Service):


ionic details (from ionic info):


Ionic CLI : 5.4.1 (C:\Users\Admin\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.10.0
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0


Capacitor CLI : 1.3.0
@capacitor/core : 1.3.0


Cordova CLI : not installed
Cordova Platforms : not available
Cordova Plugins : not available


cordova-res : not installed
native-run : not installed


NodeJS : v12.10.0 (C:\Program Files\nodejs\node.exe)
npm : 6.10.3
OS : Windows 7


Don’t use http://localhost, use IP, 192.168…


@darrenseow9 any solutions? i am encountring the same problem !!!

Hi, I have solved my issue by changing localhost to the ip address of my laptop.

1 Like

thank you saved my day

1 Like