React Native: Cannot connect device to packager (npm start)

 
9 Kudos
Don't
move!

I just started to give React Native a try. I followed the tutorial, changed localhost to my MacBook’s IP address, but for some reason, I couldn’t connect my device (iPhone 5) to the React packager server, which I started via npm start in the React project’s root directory.

The error in Xcode was a timeout:

http://192.168.1.5:8081/index.ios.bundle?platform=ios&dev=true&hot=true
2016-06-22 17:03:37.615 [error][tid:main][RCTWebSocketManager.m:84] WebSocket connection failed with error Error Domain=NSPOSIXErrorDomain Code=60 "Operation timed out"

I noticed that I couldn’t open the packager server from Safari on the device as well (http://192.168.1.5:8081), which I found odd.

Then I tried to find a solution for the search term ios safari connect local webserver and this is the answer:

http://stackoverflow.com/questions/12657651/connect-device-to-mac-localhost-server

If your iOS device can’t connect to the React Native packager server, although everything is set up flawlessly, JUST DISABLE AND ENABLE YOUR MAC’S WIFI.

Stupid thing, but it works. I just wasted an hour on this 😤