Faisal Usman
Faisal Usman

Reputation: 95

Could not connect to development server on android emulator

When i run a react native simple app using command.react-native run-android.Then i got an error "could not connect to a development server, although my packager is also run.

Upvotes: 2

Views: 10172

Answers (3)

Pratik Gondaliya
Pratik Gondaliya

Reputation: 420

Solution:

execute below line.

adb reverse tcp:8081 tcp:8081

So, when you execute this command, it establishes a connection between port 8081 on your computer and port 8081 on your Android device.

Upvotes: 0

John Zhang
John Zhang

Reputation: 55

Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

https://stackoverflow.com/a/53158627/1490685

Upvotes: 0

perotta
perotta

Reputation: 146

There is a few things you can try to solve this.

From the React Native official docs (https://facebook.github.io/react-native/docs/troubleshooting) you could try to "terminate the process on port 8081" by running:

$ sudo lsof -i :8081
$ kill -9 <PID>

You will run the second command on all PIDs that are using port 8081 (this will terminate your emulator too).

Then, restart the emulator and in one terminal, run:

$ npm start

and on a second terminal:

$ react-native run-android

Hope this can help!

Upvotes: 3

Related Questions