Home » Android » android – Crashlytics connection refused – failed to connect to failed to connect to api.crashlytics.com

android – Crashlytics connection refused – failed to connect to failed to connect to api.crashlytics.com

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m receiving the following error when starting my app. Configured Crashlytics with the plugin – appropriate entries in build.gradle, AndroidManifest.xml, crashlytics.properties exists. Starting Crashlytics from my Application class. I get this every time. I’m not behind a proxy or anything.

E/Crashlytics﹕ Error performing auto configuration.
com.crashlytics.android.internal.aD: java.net.ConnectException: failed to connect to api.crashlytics.com/127.0.0.1 (port 443) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
        at com.crashlytics.android.internal.ay.a(SourceFile:2582)
        at com.crashlytics.android.internal.ay.b(SourceFile:2562)
        at com.crashlytics.android.internal.ay.b(SourceFile:2548)
        at com.crashlytics.android.a.a(SourceFile:81)
        at com.crashlytics.android.a.a(SourceFile:50)
        at com.crashlytics.android.Crashlytics.a(SourceFile:895)
        at com.crashlytics.android.Crashlytics.a(SourceFile:54)
        at com.crashlytics.android.t.a(SourceFile:839)
        at com.crashlytics.android.internal.aa.run(SourceFile:13)
        at java.lang.Thread.run(Thread.java:841)
 Caused by: java.net.ConnectException: failed to connect to api.crashlytics.com/127.0.0.1 (port 443) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
        at libcore.io.IoBridge.isConnected(IoBridge.java:223)
        at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
        at libcore.io.IoBridge.connect(IoBridge.java:112)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
        at java.net.Socket.connect(Socket.java:843)
        at com.android.okhttp.internal.Platform.connectSocket(Platform.java:131)
        at com.android.okhttp.Connection.connect(Connection.java:101)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
        at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
        at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
        at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254)
        at com.crashlytics.android.internal.ay.i(SourceFile:2486)
        at com.crashlytics.android.internal.ay.j(SourceFile:2499)
How to&Answers:

Hemal from Crashlytics here. Can you check if any ad-blocking software is interfering with the connection?

Answer:

I had the same problem on Xiaomi M4. As was mentioned above if you don’t have any ad-blocking application then the main reason is /ets/hosts file.

You can check this guess from command line:

adb shell # run a shell there
cat /etc/hosts | grep crashlytics # print file content and filter it by 'crashlytics' word

and if you see something like this list of lines then it’s that problem which you are looking for:

127.0.0.1 api.crashlytics.com
127.0.0.1 apps.crashlytics.com
127.0.0.1 beta.crashlytics.com
127.0.0.1 blog.crashlytics.com
127.0.0.1 calendar.crashlytics.com
127.0.0.1 crashlytics.com
127.0.0.1 docs.crashlytics.com
127.0.0.1 download.crashlytics.com
127.0.0.1 e.crashlytics.com
127.0.0.1 report.crashlytics.com
127.0.0.1 reports.crashlytics.com
127.0.0.1 settings.crashlytics.com
127.0.0.1 support.crashlytics.com
127.0.0.1 try.crashlytics.com
127.0.0.1 www.crashlytics.com

To fix this problem you should comment them. The idea how to do that I found here, but I couldn’t edit file by vi. So I just pulled, changed and pushed back the hosts file. Be attentive: your device must be rooted to do this.

adb pull /etc/hosts ./<your_computer_directory> # get hosts file from device 

just comment lines like this:

#127.0.0.1 api.crashlytics.com
#127.0.0.1 apps.crashlytics.com
#127.0.0.1 beta.crashlytics.com
#127.0.0.1 blog.crashlytics.com
#127.0.0.1 calendar.crashlytics.com
#127.0.0.1 crashlytics.com
#127.0.0.1 docs.crashlytics.com
#127.0.0.1 download.crashlytics.com
#127.0.0.1 e.crashlytics.com
#127.0.0.1 report.crashlytics.com
#127.0.0.1 reports.crashlytics.com
#127.0.0.1 settings.crashlytics.com
#127.0.0.1 support.crashlytics.com
#127.0.0.1 try.crashlytics.com
#127.0.0.1 www.crashlytics.com

You can’t push it back without root rules. So push it into some tmp user directory:

adb push ./<your_computer_directory>/hosts /mnt/sdcard/hosts

Then enter as root and replace /etc/hosts file:

adb shell # run a shell there
su # become the root (don't miss confirmation request!)
mount -o remount,rw /system # allow to write
cp /mnt/sdcard/hosts /etc/hosts
rm /mnt/sdcard/hosts
mount -o remount,ro /system # get things back to normal
exit # unroot
nslookup YourBlockedAdSite.Net # check if it works
exit # good bye

Profit!

Answer:

Faced same problem, AdAway blocked crashlytics.com. Just added this host to white list.

Answer:

Check whether your device is installed with any kind of ad blocking software, or your hosts file is modified to block ads.
If your device is rooted then you can check hosts file under /etc/hosts for “127.0.0.1 crashlytics.com” line. Probably this line is causing that issue.

Add crashlytics.com to white list of AdAway and test your app.

Cheers

Answer:

If you have AdAway installed as an ad blocker. You can whitelist Crashlytics APIs by following these steps:

  • From the AdAway Menu, select “Your Lists”.
  • Select the (second) tab labelled “WHITE”.
  • Tap the plus button on the action bar, a hostname prompt should appear.
  • Enter *.crashlytics.com, then tap add.
  • It should appear as a list item under the “WHITE” tab, ensure it is checked.
  • Go back to the main menu, then download and apply ad blocking again.

Your device should be able to access Crashlytics APIs now.

P.S.: Even if you have no ad blocking software installed, some mobile phone manufacturers have a default blacklist enabled on their device as some sort of ad blocking feature. Usually, there’s a settings option to disable it. But your mileage may vary. You can check your android device’s host file (/etc/hosts) to make sure it’s not from your manufacturer (if you’re not rooted).
Also, VPN software may block hosts via DNS, so be sure to check that as well.