React Native Connect to 127.0.0.1:8888 failed in Android caused by Charles Proxy
After using Charles proxy for inspecting network traffics from Android apps, then quits Charles. Sometimes, Charles may not reset the proxy settings and it can cause internet connection issues such as when you go to the browser, it says there is no internet connection even if you do have the wifi. If you are running react native in development mode where you android app is running on the metro bundler packager server, the react-native run-android
command might fail to start the server with this error message:
A problem occurred configuring root project 'my-app'. > Could not resolve all artifacts for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:4.0.0. Required by: project : > Could not resolve com.android.tools.build:gradle:4.0.0. > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.pom'. > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.0/gradle-4.0.0.pom'. > Connect to 127.0.0.1:8888 [/127.0.0.1] failed: Connection refused (Connection refused)
Those network issues happens after quitting the Charles and if you start Charles again, those issue will be resolved. When these issues happens after quitting Charles, it’s likely that Charles did not reset the proxy setting when it is closed. If the proxy setting is not set back to the setting you previous had before starting Charles, the system is trying to connect to the Charles Proxy, but Charles Proxy is no longer running, which in turn cause the no network issue. The following are different ways to resolve this network issue when it happens after using Charles Proxy.
1. Restart your computer. This will reset the proxy setting back to what you had before using the Charles Proxy.
2. On Mac, go to System Preferences -> Network -> Advanced -> Proxies -> make sure those are unchecked: Web Proxy (HTTP) and Secure Web Proxy (HTTPS)
3. For the Android Connect to 127.0.0.1:8888 failed issue from the gradle, kill all gradle daemons and start run android again with these commands
pkill -f '.*GradleDaemon.*' react-native run-android
Search within Codexpedia
Search the entire web