Application error. The connection to the server was unsuccessful

Thanks @pierro, Actually the issue is only with android 4.4.4 devices. In other mobiles it works!

1 Like

I found some solution for this, but this is not the optimal solution

https://forum.ionicframework.com/t/app-error-and-cordova-deviceready-not-fired/50996

1 Like

I don’t like it either.

This is not really a solution, it will just delay the error.
Instead of popping up right away, it will wait for 70seconds to pop up. Still bad. :confused:

1 Like

Add the next line into the config.xml in side the tag.

<preference name="loadUrlTimeoutValue" value="700000" />

31 Likes

I once had similar problem when I used a : in an img tag. I was using angular’s one time binding. Replacing img with ng-img resolved my problem. Hope this helps

@maruti did you find a solution to this? I’m having the same issue.

As I have mentioned in my previous comment, I could resolve this code.
Add the next line into the config.xml in side the

   <platform name="android"><preference name="loadUrlTimeoutValue" value="700000" />
11 Likes

I am also facing this problem long time finally solved this issue using

<preference name="loadUrlTimeoutValue" value="700000"/>

Add this to config.xml only and run that work fine.

10 Likes

Perfect solution… thanks!

I dont know why but for my case its probably not solving. Any other solution?

Dont worry Guys, finally its works. But I had to remove android, then re-add platform.

Thanls

2 Likes

I was facing this error too.

The cause of this failure is something that can’t be loaded by any reason. For me, was an external script (it must be external) that was returning a 404.

Solution was fixing this 404 at the server, and adding async defer to script declaration.

<script async defer src="http://foo.com/scripts/bar.js></script>

And… fixed it!

No need to remove and add again the platform.

4 Likes

Hi!
It works for me :slight_smile:

<preference name="loadUrlTimeoutValue" value="700000" />

But what means value=“700000” ?
Seconds or milliseconds ??

Thanks,

3 Likes

According to Cordova documentation

LoadUrlTimeoutValue (number in milliseconds, default to 20000 => 20 seconds): When loading a page, the amount of time to wait before throwing a timeout error.

1 Like

Thank youuu @fredDS :wink:

<platform name="android"><preference name="loadUrlTimeoutValue" value="700000" />

Do we need to mention platform name as well ?

or simply <preference name="loadUrlTimeoutValue" value="700000" />

If I am developing a application for both iOS and android platform

Since the error only occurs on Android platform, the first option is the best.

    <platform name="android">
        <preference name="loadUrlTimeoutValue" value="700000" />
    </platform>
2 Likes

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