title: React Native: Could not connect to development server
body: <p>I have a very simple React Native project that I am trying to get working. It is an iOS project that simply adds a RCTRootView to a UIViewController. When I run the app from Xcode I get a red screen with the error:</p>
  
  <pre><code>Could not connect to development server.
  
  Ensure the following:
  - Node server is running and available on the same network - run 'npm start' from react-native root
  - Node server URL is correctly set in AppDelegate
  </code></pre>
  
  <p><strong>AppDelegate.h</strong></p>
  
  <pre><code>@property (strong, nonatomic) RCTRootView *rootView;
  </code></pre>
  
  <p><strong>AppDelegate.m in <code>application: didFinishLaunchingWithOptions:</code></strong></p>
  
  <pre><code>NSURL *jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"];
  self.rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"HelloReact" initialProperties:nil launchOptions:launchOptions];
  </code></pre>
  
  <p><strong>ViewController.m in <code>viewDidAppear:</code></strong></p>
  
  <pre><code>AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  [self.view addSubview:delegate.rootView];
  </code></pre>
  
  <p>I am at a loss on how to resolve this. I have tried all of the following:</p>
  
  <ul>
  <li>npm start</li>
  <li>npm start --reset-cache</li>
  <li>Deleted node_modules directory and reinstalled</li>
  <li>Uninstalled and reinstalled node, watchman, react-native, and npm</li>
  <li>Tried on physical device and simulator</li>
  </ul>
  
  <p>Does anyone see anything that is wrong in my code or know what the issue might be? I'd be willing to converse over email or phone to solve this. I am getting desperate.</p>
  
  <p>I was having simultaneous issues. Here is the other question I asked which may contain some info: <a href="https://stackoverflow.com/questions/43924629/react-native-unable-to-resolve-module">React Native: Unable to Resolve Module</a></p>