Application error. The connection to the server was unsuccessful

I get the same error and nothing of this tips helps me. Then i find that i need to change running address with “ionic address” . That helps me finnaly!

2 Likes

I had the same error. I’ve noticed, that the parameter --livereload from the command ionic cordova run android --device --livereload modifies the config.xml in my project.

It adds the following tags to it:

  • <allow-navigation href="http://[IP of my pc in my home network]:8101" />
  • <content original-src="index.html" src="http://[IP of my pc in my home network]:8101" />

That ended in it, that the apk on my real Android Device has shown the error, that The connection to the server was unsuccessfull.

So I added manually the following tags to my config.xml right at the beginning:

  • <allow-navigation href="*" />
  • <content src="index.html" />
  • <content original-src="index.html" />

If You have a texteditor, which supports live-reloading of files and You run the command ionic cordova run android --device --livereload with Your opened config.xml again, You will be able to notice, that the command adds just <allow-navigation href="http://[IP of my pc in my home network]:8101" /> to the very bottom of the config.xml.

That ended up working for me. But just keep in mind, that this solution is just for developing.

Hope it helps someone of You guys.

Cheers

11 Likes

I was having this error and i noticed that device had wifi off, i just had to enable wifi. Device must be in same network to connect with cordova run

4 Likes

If that’s true, then some resource somewhere in your script is reaching for a local file directory that went offline.

I’d assume you’re making an online connection and the feedback method didn’t receive a status 200 which prevented the completion.

Regards,
Neonic1

Hi.

May I ask you how you do that?

Sorry for the newbye question, but I’m stuck with this problem and cannot test anything that needs a device (like QR code or GPS)… if I had the delay, my application just stays there, freezed with a blank screen.

BTW I’m using Ionic 3

Thanks

I think this solution is not good because the problem is the app is slow to locate de index.html and your solution is to set hight timeout connection. Now, i question: Why the ionic app is slow to found this file?

1 Like

Work like a charm. Could you explain how it work

thanks @Unkn0wn0x , I work for me

After reading your comment I ran the command without --livereload and it worked!..:smiley:
Also I’ve noticed, to use --livereload mobile and PC must be in the same network.

1 Like

Also android 5 tablet , i3 app

thank you so much. it’s work.

3 Likes

Very Nice Solution. thank you very much

Thanks it works, but why? What is the error? What generate it?

Same here, thanks a lot for this, I’m looking already hours for this…

Thanks a lot it works!!!

It works for me, thanks!

Okay so , I tried this approach and it works!

Open two terminals . Before deploying your app , run the server in the first terminal.(ionic serve)
Then , in the second one , run the app. It’ll work!

1 Like

connection to the server was unsuccessfull error ocuured when generating a release apk using ionic framework, in building android apk there is no error. anyone plz help me

I found in my android phone an item (french name “application à deboguer”) in the “parameters”/“development options” menu in which my ionic app needed to be selected in order to solve this issue.

I hope this will help

The only and best solution is setting the timeout really high?
Does this popup happen for people on release builds? I can see a dev build could be slower and cause this issue.

Does a new version ionic android fix the issue?