react-native-webview: Android - net::ERR_NAME_NOT_RESOLVED
Bug description:
When trying the example of usage Android returns an error Encountered an error loading page {"canGoBack": false, "canGoForward": false, "code": -2, "description": "net::ERR_NAME_NOT_RESOLVED", "loading": false, "target": 855, "title": "Webpage not available", "url": "https://reactnative.dev/"}
Searching on Google i saw something about AppRegistry if this screen its going to be my root page, but is not my case, and trying on iOS everything is working just fine
To Reproduce:
Try the example of usage in a functional component
import React, {useRef, useState} from 'react';
import {SafeAreaView} from 'react-native';
// More imports
const HomeScreen = () => {
// More stuff
return (
<SafeAreaView>
<WebView source={{uri: 'https://reactnative.dev/'}} />
</SafeAreaView>
);
};
Expected behavior:
Screenshots/Videos:
iOS (working)

Android (not working)

Environment:
- OS: macOS
- OS version: 10.15.6
- react-native version: 0.61.5
- react-native-webview version: 10.8.3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 42 (1 by maintainers)
I’m experiencing this problem as well.
The emulator has no access to internet, so try it:
related thread: https://stackoverflow.com/questions/42736038/android-emulator-not-able-to-access-the-internet
I had the same issue on my Mac, and it turned out that I did not have access to internet inside my Android simulator. I followed those instructions and now it works perfectly: https://stackoverflow.com/a/49332186.
I encountered this error sometimes when switching back and forth from Webview screen to different screens. In my testing, I was repeatedly clicking into Screen with WebView and going back to previous page.
Is this a problem when the Component unmounts?
In my case, it really was a DNS issue because the REST API did not provide IPv6 addresses. The Problem occurred in Android Firefox and Android Opera as well which was reason to look further.
It was solved by the API team when they enabled IPv6, so it seems react-native-webview does not re-try a lookup in IPv4 space after a IPv6 lookup has failed. This seems to be the same behaviour that Firefox Android & Opera Android exhibit so I would not see this as a bug, but a fault due to outdated development practises of our API team.
Thanky you for your patience and I hope this information helps someone.
You could use a UI logger for the website that way you can monitor what’s happening by inspecting the UI logger. You can checkout this library: https://www.npmjs.com/package/electrode-ui-logger
On Wed, Aug 2, 2023 at 2:57 PM ThaJay @.***> wrote:
+1 happening on a Physical Android device. React-native version: 0.70.5 React Native webview: 11.13.0
For most case in android you have to check the internet connectivity from the simulator if the wifi is connected but there is no internet connectivity this error will persist.
Solution
This was how I got mine working
still searching for solutions…
this problem in my case is cause by the different file path on iOS and Android for example the iOS works fine but Android not well fix it by change the source
to
Any update or solution? It is happening to me on my physical device. Same implementation I use for android I am using it on my iOS device and it is working fine.