Application error. The connection to the server was unsuccessful

Yet again this problem, I know.
Launching the app on android gives an “application error. The connection to the server was unsuccessful”.

Many topics on this subjects, all pointing out to potential js or css using external link.
However, I have absolutely no file using external link in my code, and mostly not in my index.html

The strangest part is that this problem suddenly happened to all my android users last night for no reason at all. The same build that has been working for weeks sudddenly got this error on every android device. This morning, everything fell into place again. However, I do not want that to ever happen again.

This whole thing just seem so random, how could it happen like that on every device without even needing a database connexion at that point ?

Please anyone, enlighten me.

9 Likes

Any solution for this? I am stuck with this issue. can anyone from ionic team help here?
@mhartington

I am running out of time to deliver just because of this issue :expressionless:

Device is running on 4.4.4, ionic info is below

Your system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.36
ios-deploy version: 1.8.6 
ios-sim version: 5.0.8 
OS: Mac OS X Sierra
Node Version: v4.6.0
Xcode version: Xcode 8.0 Build version 8A218a
3 Likes

Although I find this method infinitely ugly, I found it online and it might be working in your case:

https://www.robertkehoe.com/2013/01/fix-for-phonegap-connection-to-server-was-unsuccessful/

However, I really hope we can find a cleaner solution to this problem.
And on top of it, I would love an explanation why it happened to me in a production app that was working fine for weeks.

3 Likes

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" />

32 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.

11 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