question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isInternetReachable returns false even internet is connected

See original GitHub issue

Environment

System:
    OS: macOS 12.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Memory: 30.75 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.2.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.9.0 - /usr/local/bin/npm
    Watchman: 2022.05.16.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 26, 29, 30, 31, 32
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0
      System Images: android-26 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8139111
    Xcode: 13.3/13E113 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: ^0.66.4 => 0.66.4
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

Android

Versions

  • Android:
  • iOS:
  • react-native-netinfo: ^8.3.0
  • react-native: ^0.66.4
  • react: 17.0.2

Description

Sometimes isInternetReachable returns false even when interent connection is active. Actually, the issue persists when enabling Airplane mode after that isInternetReachable returns false. but if we remove Airplane mode then WIFI connects automatically and is also able to do API requests but isInternetReachable still returning false.

This behavior occurs sometime only. otherwise, it works perfectly.

we use useNetInfo() hooks to identify isInternetReachable status.

import { useNetInfo } from "@react-native-community/netinfo";

const NetworkConnection = () => {
  const netInfo = useNetInfo();
  const isNoConnection =
    (netInfo?.type !== "unknown" &&
      netInfo?.type !== "none" &&
      netInfo?.isInternetReachable === false) ||
    (netInfo?.type !== "unknown" && netInfo?.type === "none");
  return (
    <View style={CommonStyles.flexRoot}>
      {isNoConnection ? (
        <View style={STYLES.noInternetContainer}>
          <FontedText
            text="No internet connection"
            fontSize={widthToDp(14)}
            fontFamily={AppFonts.DMSansRegular}
            color={Colors.darkRed}
          />
        </View>
      ) : null}
    </View>
  );
};

Reproducible Demo

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
JensenBlakecommented, Aug 24, 2022

Facing the same issue

4reactions
phucph1998commented, Aug 11, 2022

me too

Read more comments on GitHub >

github_iconTop Results From Across the Web

The key isInternetReachable is always returning false for a ...
I'm working on implementing network status check in a project with dynamic data and checking for internet reachability whenever an API call is ......
Read more >
React Native| NetInfo to check whether has internet connection
In this tutorial, we are going to create an expo|React Native app that can detect whether has internet connection or not.
Read more >
ReactNative Network Configuration | by Cbisum - Medium
When all ports are closed in the network even IsConnected property is true, isInternetReachable will be null. That means we will not be...
Read more >
NetInfo - React Native
Available on all platforms. Asynchronously fetch a boolean to determine internet connectivity. NetInfo.isConnected.fetch ...
Read more >
A Guide To React Native Offline Support - GeekyAnts Tech Blog
Apps need an active internet connection to communicate with their respective servers and ... isInternetReachable === false) return ( <View ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found