Create-react-native-app: Network Response Time Out Error

Created on 1 Apr 2017  路  71Comments  路  Source: expo/create-react-native-app

Uncaught Error: Java.net,sockettimeoutException: failed to connect to after 10000ms in android after scan QR code

Most helpful comment

This issue is caused by having virtual network devices, usually installed by virtual machines.
React Native chooses the first available network IP which may not be the correct one.

To fix this issue you have to find your local IP address, by entering the Command Prompt and typing:
ipconfig
or
ipconfig /all

If you are on WiFi, look for the WiFi section, and note down your IPv4 Address
If you are on Ethernet, look for the Ethernet Adapter section, and note down your IPv4 Address

For Example:

untitled

Once you have your local IP address, navigate to your project folder inside Command Prompt.
Inside your project folder run the command.

set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address

Replace my-custom-ip-address with your IPv4 Address you noted down earlier.

For example:

cmd_2017-06-14_22-42-00

Then run npm start
Scan your QRCode through the Expo app and it should be working.

All 71 comments

Hi! Without the information from the new issue template it's very difficult to help you debug this. In general, you want to make sure that you can reach the development server from your phone. If you take the URL that CRNA prints at startup, and replace exp:// with http://, you should be able to reach that in your phone's browser and see some JSON. If you can see that JSON, but scanning the QR code doesn't work, please open a new issue and complete all of the required sections of the new issue template.

same issue
whatsapp image 2017-04-24 at 13 14 44

@yash2code first check your ip address of your pc .... write ipconfig on cmd ... and then write set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' then start your project again ...

@aayanqazi

Ethernet adapter VirtualBox Host-Only Network #2: IPv4 Address. . . . . . . . . . . : 192.168.56.1

Now, what to write in place of 'my-custom-ip-address-or-hostname'

@yash2code Your ipv4 address that found in your ipconfig

@aayanqazi tried that but didnt worked :(

@dikaiosune please re open this issue

@yash2code can u send screenshot of ipconfig command ?

@steadycoding url timeout in phone's chrome browser but works in desktop chrome browser. Using hotspot as said.

@aayanqazi my screenshots ofipconfig

capture
capture1

Use Wireless LAN Adapter WI-FI Ipv4 Address 192.168.43.244 @yash2code

@aayanqazi when I goto exp://192.168.43.244 , it starts fetching js bindle but app doesnt opens and restarts my phone giving error this.stream.clearLine() is not a function , Also , on scanning qr code gives same error: Network response time out error

@dikaiosune I think issue needs to re open .

i am getting the same issue as @yash2code
Have done all the steps which you mentioned but still the problem persists.
My PC and phone are both connected to wifi. In browser , if i hit the ip address i am getting the json but in phone its giving timeout error.
Here is the screenshot of the ipconfig
ipconfig

@Jitender-Rathore send the full screenshot of ipconfig

the sccreenshot which i upload is a full one .
I also tried with hotspot .This time i was getting the json when i enter the ip address in mobile browser and desktop but expo was showing the same error

from my screenshot ........i used this 192.168.43.244 and it worked

how to fix ? I got the same problem

@phamios show the output of ipconfig

This issue is caused by having virtual network devices, usually installed by virtual machines.
React Native chooses the first available network IP which may not be the correct one.

To fix this issue you have to find your local IP address, by entering the Command Prompt and typing:
ipconfig
or
ipconfig /all

If you are on WiFi, look for the WiFi section, and note down your IPv4 Address
If you are on Ethernet, look for the Ethernet Adapter section, and note down your IPv4 Address

For Example:

untitled

Once you have your local IP address, navigate to your project folder inside Command Prompt.
Inside your project folder run the command.

set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address

Replace my-custom-ip-address with your IPv4 Address you noted down earlier.

For example:

cmd_2017-06-14_22-42-00

Then run npm start
Scan your QRCode through the Expo app and it should be working.

Hello,

I have the same issue.

I try this : set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address
And also the solution from Stack Overflow (open the port 19000 from the machine)
It still doesn't work.

I can't access the URL from my phone browser either.

Thanks for your help

I am using git bash and had to use
export REACT_NATIVE_PACKAGER_HOSTNAME='192.168.1.123'
instead of set REACT_NATIVE_PACKAGER_HOSTNAME
still having issues but got past the wrong ip issue.

FYI when you run npm start it tells you in the output the IP it's using. If that IP is not the IP you want then the REACT_NATIVE_PACKAGER_HOSTNAME environment variable is not set properly

I've had the same issue. The problem is that the command yarn start or npm start finds the first enabled network adapter it finds which just happens to be the adapter for VirtualBox on my (and many other machines). The solution is to either:

  • manually set REACT_NATIVE_PACKAGER_HOSTNAME environment variable, or
  • disable the unused network adapter in Windows' Network Connection (see image)

The problem is that Expo finds the first Network adapter, and not the active network adapter that provides the internet connection.

untitled

I tested all solutions but Expo still encounters timeout error, it's really on the nerve! deploying using react-native cli was much much better and easier, now I donno why even cli has some issues with watchman and changing the files doesn't reflect on device.

Windows 10
react native 0.47

i used below command and scan QR with expo app and its work !!
npm start
but when i use open on android , still has time out error .

@CyrisXD answer did it for me!! check it out!

I went around disabling virtualhoust, firewalls, etc... but what really happened is that It was exporting the wrong ip adress.

Remember that if you are on windows you need to do "export REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address" instead of "set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address"

This worked for me: I've downloaded adb from android tools then adb reverse tcp:19000 tcp:19000, and I didn't put IPv4 address as recommended... my localhost is 127.0.0.1, so manually entering exp://127.0.0.1:19000 in Expo App worked for me. I don't know why is this, just trial and error

for anyone who's still facing this problem on windows
1) make sure your phone is connected to the same network as you computer
2) make sure that windows firewall isn't blocking that port, if so make an exception for that port (1900 in my case)

My solution I found while struggeling with the same problem on another machine (osx sierra), while it was working on my first one (osx sierra) - McAfee was blocking it (which was only installed on the second one); disabled it's Firewall and voil脿, it works (ios/android)

I'm having the same issue although my setup is really weird and maybe it's just not possible to get this working.

I have a USB broadband dongle and my internet is via a mobile network (4G) plus I'm on Linux (Fedora) and well these devices are not known to work amazingly on Linux to begin with. I reckon that the ISP may well be blocking ports, though, or otherwise interfering with traffic in some way, or something like that (UK mobile networks are notorious for this).

I've tried adding the port to the firewall and so on and so forth (read through the entire thread) but to no avail. Can anyone try to help me?

@sustained Have you tried the solution I posted before? Your phone doesn't need to be on the same network, as it will be connected via USB port (You have to enable USB Debugging on your phone, this is for Android devices). You will need to download adb from Android SDK Platform Tools

I'm actually happy to report that I got it working by opening ports 19000, 19001 and 19002!

@hrastnik had it right, works on my windows machine by disabling all other network adapters, as mentioned by hrastnik, expo seems not quite smart when detecting the correct network adapter, not looking for the active one, but instead the first one... So disable all other network adapters :)

If you have several network connections, but can't disable any of them, here is nice solution how to do it on Windows machine
<spoiler>You need to set up metrics for them</spoiler>
https://stackoverflow.com/a/45179856/2089991

Hi, I just want to share with you what cause 'Network Response Time Out Error' error in my case. It wasn't firewall, it wasn't virtual box. My computer with windows which I use to host React Native App was connected to my home network but was unreachable from any other computer (or phone) because it was setup as a "Guest or public" network profile. When I changed this network profile to "Private" it started working :) cheers

Can you try after "Windows firewall " Off ?

My issue probably stems from the fact that the app is running from a Linux Virtual machine. How can I get my device and the virtual machine to be on the same network?

I have this issue in a production application where expo doesnt connect to ip.

Exception java.lang.RuntimeException: java.net.SocketTimeoutException: failed to connect to [REDACTED_DOMAIN_NAME]/[REDACTED_IP_ADDRESS] (port 443) after 10000ms
host.exp.exponent.kernel.ExpoViewKernel.handleError (ExpoViewKernel.java:76)
host.exp.expoview.ExponentActivity$3$1.onError (ExponentActivity.java:195)
host.exp.expoview.Exponent$2.onFailure (Exponent.java:439)
host.exp.exponent.network.ExponentHttpClient$2$1.onFailure (ExponentHttpClient.java:95)
expolib_v1.okhttp3.RealCall$AsyncCall.execute (RealCall.java:142)
expolib_v1.okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:818)
arrow_drop_down
Caused by java.net.SocketTimeoutException: failed to connect to [REDACTED_DOMAIN_NAME]/[REDACTED_IP_ADDRESS] (port 443) after 10000ms
libcore.io.IoBridge.connectErrno (IoBridge.java:169)
libcore.io.IoBridge.connect (IoBridge.java:122)
java.net.PlainSocketImpl.connect (PlainSocketImpl.java:183)
java.net.PlainSocketImpl.connect (PlainSocketImpl.java:456)
java.net.Socket.connect (Socket.java:882)
expolib_v1.okhttp3.internal.platform.AndroidPlatform.connectSocket (AndroidPlatform.java:63)
expolib_v1.okhttp3.internal.connection.RealConnection.connectSocket (RealConnection.java:220)
expolib_v1.okhttp3.internal.connection.RealConnection.connect (RealConnection.java:146)
expolib_v1.okhttp3.internal.connection.StreamAllocation.findConnection (StreamAllocation.java:186)
expolib_v1.okhttp3.internal.connection.StreamAllocation.findHealthyConnection (StreamAllocation.java:121)
expolib_v1.okhttp3.internal.connection.StreamAllocation.newStream (StreamAllocation.java:100)
expolib_v1.okhttp3.internal.connection.ConnectInterceptor.intercept (ConnectInterceptor.java:42)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
expolib_v1.okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:93)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
expolib_v1.okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:120)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
host.exp.exponent.network.ExponentNetwork$3.intercept (ExponentNetwork.java:140)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
expolib_v1.okhttp3.RealCall.getResponseWithInterceptorChain (RealCall.java:179)
expolib_v1.okhttp3.RealCall$AsyncCall.execute (RealCall.java:129)
expolib_v1.okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:818)

Hi,

I had to both disable all other network adaptors AND change the network setting to "private" to get Expo working in Windows. Thank @hrastnik and @czytelny .

I can confirm disabling the Windows Firewall fixed this issue for me.

Same problems, and working without firewall.
What i did to fix it, on Windows 10.

  1. The famous "set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address"
  2. Authorize ports 19000, 19001 and 19002
    -- https://stackoverflow.com/a/44600431/1443984
  3. change the network to "private" (thanks @sumethy)
    -- On Windows 10, you can left click on the "wi-fi" icon in system tray > "Properties" > switch to "Private" in the "Network Profile" section.

It fixed this issue for me.

Hi,

I got same problem and i fixed with turning off all Ethernet Adapters except Wi-Fi Ethernet adapter. If you using any adapter such as VirtualBox Adapter, Hamachi Adapter etc. turn off all of them.

When u type "npm start" it will give you new IP adress and verify QR code again and it will works!

Ubuntu 16.04 same problem, it's fixed just by disabling firewall sudo ufw disable

Same problem, in my host pc if I use the IP I get: This site can鈥檛 be reached
If I use http://localhost:/19000 it shows a json file.

In my phone nothing works, oh man.

I had the same issue on Windows 10. Disabling virtual network adapters and allowing the port through windows firewall fixed it. Thanks to @CyrisXD and @anass05 .

@mkmpvtltd1 thanks that worked for me!

@CristhianUNSa Amazing.. after a couple of days of searching your solution works perfectly THANK YOU SO MUCH!

If you have tried all of the above solutions and you still can't connect to your computer from your mobile device and your both devices get connected throw a router, then it might be that you have the wireless isolation feature turned on somewhere in your router's configuration.

When this feature is turned on, it disallows clients connected to the Wi-Fi network to interact with devices connected to the wired network, nor can they communicate with each other. They can only access the Internet.

You can read more about this feature here: https://www.howtogeek.com/179089/lock-down-your-wi-fi-network-with-your-routers-wireless-isolation-option/

I'm developing on a Centos 7 VirtualBox machine. CyrisXD's advice was the final piece I needed. Other than that, if you're developing on VirtualBox, I suggest disabling the host ethernet connection and setting up the USB filter on your guest (VM) to "add the USB filter with all fields set to the values of the selected USB device..." for the phone/tablet and maybe also for the Wifi card on your host machine. My network is a bridged adapter to the Wifi Adapter on the host.

Looks like any type of Connection affects to Packager server, so just disable un-used connections and everything works.

(without custom ip REACT_NATIVE_PACKAGER_HOSTNAME)

image

changing the network to private in windows 10 works for me. thanks @sumethy @AurelGit

Uninstalling any virtual machine program solved the problem for me.
Seems like it was using the IPV4 from the virtual machine and not from the Lan adapter.

I only got it following @mkmpvtltd1 stackoverflow link steps. But before, I did all people said in this issue too Lol. So if you're facing this problem, do all them :)

If you have used create-react-native-app to setup your project, I solved this issue by setting the hostname in the package.json file with in the project.

Package.json

"android": "set REACT_NATIVE_PACKAGER_HOSTNAME={your wifi ip address} && react-native-scripts android",

I'm running the app in windows 10.

@AurelGit Thanks man. Windows 10 users, just go straight towards this guy's solution. Works perfectly!

I have the same problem today on Win 10 and fix using @CyrisXD instructions.. Thanks!

Thanks @AurelGit ! It works for Windows 10!

I faced same issue, and found that is was due to firewall.
My network was public and in firewall setting Node.js is only allowed to private network.
Allowing it for public solve my problem.

For me, none of the above worked, but the following worked perfectly: access your router settings and disable the "AP Isolation" property. Connect your devices again to the wireless and then the router will let connected devices communicate with each other.

For me, it was a firewall problem. I was developing in WSL and the ports were being blocked by windows firewall. I simply added a new rule to my firewall that allowed all ports from within WSL and everything worked fine afterwards.

I think this happened because react native use wrong ip... so when expo try to connect... it failed

this happened to me because I have virtual ethernet (Because VBox)...I solved the problem by following Muhammad Hannan's solution from https://stackoverflow.com/questions/47966887/expo-lan-configuration-doesnt-work-for-new-reactnative-project

I did all the above steps still the error i am getting.

System : windows 10 Home
Phone : one plus 6

Any other checks i need to do ?

Only problem is that you are not using "same local internet connection on your mobile and PC"
I have been facing the same problem but after a lot effort i figure it out

SOLUTION: Use same internet connection on your mobile(on which using expo app) and Computer (running react native app)

I did all the above steps still the error i am getting.

System : windows 10 Home
Phone : one plus 6

Any other checks i need to do ?

https://github.com/react-community/create-react-native-app/issues/144#issuecomment-424768154

@yash2code first check your ip address of your pc .... write ipconfig on cmd ... and then write set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' then start your project again ...

Still not working for me

I just can't fathom how ridiculous it is to pick a non-standard web port, and then expect people to manually open their firewall ports. Why not use ports in the normal range 3000 or 8000?

I can't change the firewall rules on my laptop due to Admin restrictions...

After some reading through the source seems it is possible with a .exprc file containing:

{
  "manifestPort": 8000
}

None of the above suggestions and solutions worked for me.

Don't forget to use Wifi on your smartphone as well!!! glad to help whoever you are ^_^ btw thanks for all the guys above! :)

And where to write it? cmd/terminal?
I am using ubuntu, I am not sure if its doing anything, is there way to check if the command worked (other than testing the expo which is not working for me as well).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JackWReid picture JackWReid  路  4Comments

FezVrasta picture FezVrasta  路  3Comments

andyvanosdale picture andyvanosdale  路  3Comments

witbybit picture witbybit  路  4Comments

FezVrasta picture FezVrasta  路  3Comments