-
Notifications
You must be signed in to change notification settings - Fork 24.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not connect to development server. Ensure node server is running #304
Comments
Did you try running |
I get this error as well when I try to run on real ios device through xcode. Is that expected? |
Run |
Ok, I will try it, I see the AppDelegate.m :
Maybe you should write it in a wiki(How to run examples ?). It's easy to freshman. |
I see this error even after running 'npm start'. Do I need to make any changes to AppDelegate.m file? |
OK. fixed the issue. I had to change the port from 8081 to 8881 as the default port is used by another process on my mac. Modifying AppDelegate.m to point to the new port worked.
|
Hopefully alleviates new issues getting created for similar problems. Addresses facebook#257 facebook#304 facebook#306 facebook#326
where is react-native directory? |
The "react-native directory" refers to the folder where your own source-code is located. |
I think "react-native root" within the error could be more clear which just as @brownieboy said, refers to the folder where the source code located. |
It worked for me -> open the APP folder in the terminal and running "react-native start". Here you can also check on which port it is running and set the same. |
I can load this URL just fine in my browser: http://localhost:8081/index.ios.bundle?platform=ios&dev=true but I still get this error. My AppDelegate appears like so: let jsCodeLocation = NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios&dev=true")
let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "App", initialProperties: nil, launchOptions: launchOptions)
let rootViewController = ViewController()
rootViewController.view = rootView
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = rootViewController
self.window?.makeKeyAndVisible()
return true |
Jamesfzhang I am having the same error as you, what is the full name of the boolean you added at the end? And does the app transport security settings dictionary live in the information list dictionary? Thanks |
@adamsythe The boolean is <key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict> |
Thanks my error disappeared when I updated my operating system :) |
I can also load the dev server resource in my browser, and also updated my info.plist as jamesfzhang suggested. But I'm still getting the red screen connection error message. Now I tried to to access the dev server resource (http://[my ip]:8081/index.ios.bundle?platform=ios&dev=true ) through a browser on my device, and that page doesn't load. I'm sure my workstation and device is on the same network. Could this be a closed port issue? |
Getting the exact same error. No problem loading from browser, can't fetch from simulator. tried @jamesfzhang solution, but still having same error. Anyone found a solution? |
I had to change the address of the dev server in the following file as well: Libraries/RTCWebSocket.xcodeproj/RTCWebSocketExecutor.m Pungsnigel, can you load the dev server resource from a browser in your device? |
I fixed this with using |
Have you tried adding your IP to list of |
@jamesfzhang Following your instruction, I was finally able to resolve the "Could not connect to development server" issue on the simulator. Thanks! |
@tkfeng Great, no problem! |
I had two problems, solutions below: 1: Could not Connect to development Server Problem 1:
SolutionAdding this to your xcode project plist.
Problem 2:
SolutionFor some reason
Then when running
Note: make sure the the port from this line: 🚀 🚀 🚀 |
@jamesfzhang I added localhost to my list of exceptions and it runs well on the simulator. I also added my local IP address 192.168.XXX.XXX but I can't get it to work on my device. Any thoughts ? |
I also had this problem (where I could access the URL from the browser on the device fine, but the app could not). I tried adding the solution 1 mentioned in @phoenixbox (originally suggested by @jamesfzhang) but that didn't work. Then I instead of using localhost as jamesfzhang suggested, I entered my IP address and put my IP in the jsCodeLocation line in AppDelegate.m and then it worked. |
Thank you so much @PhillippOhlandt! Why I need to do this on one computer and not the other baffles me, but it works! |
@dazziola yeah, after some time, it worked even without that. |
Putting this here for others. If you're debugging on a physical phone and trying to connect to the local network the xip.io domain must be DNS resolvable. Turns out my modem, a Fritzbox, blocks such DNS lookups for local domain ip addresses and I had to add an exception in my modem settings. Now I can reach my dev server on my laptop. To test if you have such a problem - dig .xio.ip if it time's out you have an issue. More information in this script, https://github.com/facebook/react-native/blob/master/packager/react-native-xcode.sh#L83 Also if you're running on a phone, you'll see in that script that NSTemporaryExceptionAllowsInsecureHTTPLoads are added for your test domain also - so you don't need to manually add them. |
check your |
I have had this problem all day using the simulator. Can not find a solution. I've tried every recommendation in this thread and it's still happening. I've even checked out what's going on with Wireshark and I'm stumped! I can navigate in the browser, but the simulator can't connect. The host, and port are the same. I've modified AppDelegate with the correct information. I've modified the plist file. No firewall. Absolutely stumped here. |
Fixed. In
And replace with:
Note the I'm not sure if this is the correct way to do this, but it's the only way to solve my issue. No idea why because the locahost issue is a bug from an older XCode, but I'm using 8.0. |
Getting same error as @jamesfzhang on the simulator too; RN 0.39 and Xcode 8.1. Tried everything here but nothing seems to be working. The packager is running but when I try to start the app through Xcode or react-native run-ios I still end up with the error. @JamesTheHacker I tried your method with both port 8081 (my default) and 8006 but not working either. Been stuck on this all day; any other options? |
@kadzier did you change |
@JamesTheHacker no dice, still got the exact same error. I finally was able to resolve the issue, however: I ended up completely uninstalling the react native cli and watchman, as well as also uninstalling npm AND node, deleting the references everywhere I could find them as per http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x. After reinstalling everything fresh I'm no longer getting this issue and everything runs as intended. I cannot even fathom what was going wrong but my guess was some sort of weird unintended dependency I created was messing things up. |
@dvabolta How to you fix isssue by ngrok? Could you please guide me step by step? |
@toanfet I just got dev bundles loading over ngrok at a coffee shop by temporarily modifying this line in //jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
jsCodeLocation = [NSURL URLWithString:@"https://4af8888.ngrok.io/index.ios.bundle"]; |
thanks everyone |
@lealife your solution saved me from night stay at office 💃 . Thankx a lot. |
Here's the simple command |
@PhillippOhlandt |
Thank |
I got this error when trying to run on my device. Fought it for 6+ hours and tried EVERYTHING. Turns out the wifi on my phone was off. Feel like a huge idiot but MAKE SURE YOUR WIFI IS ON ON YOUR DEVICE!! |
This can be resolved by the dev settings inside the android emulator , please visit my site for more information, http://gadoth.com/react-native-series-post-1-installation-setup/ |
@bighitbiker3
change the **localhost ** to your ip address ,if you have mac run Network Utility App and find your IP Address . |
Go to android/sdk/platform-tools and try running |
iOS : If you are trying to run on a device, then change the URL from |
We faced this issue, In order to fix this, solution is dead simple is below.
|
yes, you should change 127.0.0.1 to your real computer ip like 192.168.1.121. this will work as a magic on your real device, 127.0.0.1 works on your simulator only. |
it depends on some point |
Restart mac worked for me |
I run the 2048 example on Xcode and run the IOS simulator, an error occurs:

The text was updated successfully, but these errors were encountered: