Adam Katz
Adam Katz

Reputation: 6972

React native not running on localhost

React native stopped working, whenever I run it now (no matter which project) I get the error 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

URL : http://localhost:8081/index.ios.bundle? platform=ios&dev=false

Upvotes: 3

Views: 10058

Answers (4)

Khurshid Ansari
Khurshid Ansari

Reputation: 5095

I was face same problem while running in physical device.

I did as below:

  1. Open terminal and check your local ip address.
  2. Shake device(android) click on dev settings
  3. Click "Debug server host & port for device" under debugging
  4. type local ip address and port number.

note: cross check in browser ip along with port number.

Upvotes: 1

Bala Krishna
Bala Krishna

Reputation: 164

Please ensure you have done the following

1) run server using

npm start

2) if you are using actual device , make sure you are connected to same network

3) for android: run the following command and try again

adb reverse tcp:8081 tcp:8081

Upvotes: 2

Louis Lecocq
Louis Lecocq

Reputation: 1814

To debug on a real device:

  1. On iOS - open the file AppDelegate.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.

    let jsCodeLocation = NSURL(string: "http://{{YOUR IP ADRESS}}:8081/index.bundle?platform=ios")
    
  2. On Android, you can open dev menu on the device and select Dev Settings, then update Debug server host for device setting to the IP address of your computer.

Upvotes: 0

Steven Sajja
Steven Sajja

Reputation: 33

I usually just run npm start in my terminal. (OSX) I assume it would be the same on Windows

npm start 

Upvotes: 0

Related Questions