Reputation: 602
When I run my ionic app in android device, it shows an error
Application Error
The connection to the server was unsuccesful.(http://localhost:8101)
I run with the command
ionic cordova run android -lc
How i can fix this error? why this error occur?
Upvotes: 0
Views: 374
Reputation: 13125
One option in this scenario is to not pass the -l which is for livereload functionality. So just run:
ionic cordova run android
This will then compile the apk and deploy it to your phone, but won't run a web server to watch for changes.
You can still debug with Chrome in this scenario, but if you make a change to the markup and press save it won't automatically reload the app with that change. You would need to run ionic cordova run android
again to rebuild and deploy it to your phone.
On the plus side 1: after the first deploy, subsequent builds are much faster, as a gradle server is started.
On the plus side 2: if you disconnect your USB then you can still use your app. With a livereload deployed app it breaks once you disconnect.
I would actually really like to solve your problem as well. As I move around coworking spaces sometimes it seems that the network is locked down somehow and just is blocking certain ports. I haven't figured out exactly why or if there is a workaround for this.
Upvotes: 1