4

Yes i have read this but still don't know how to make it work. react native - Port 8081 already in use, packager is either not running or not running correctly Command /bin/sh failed with exit code 2

Originally i was doing this

1. react-native init Hello 2. react-native run-ios 

Then hit this "port 8081 already in use".

Did read the react doc, https://facebook.github.io/react-native/docs/troubleshooting.html

1. cannot kill the process using 8081, it keeps on coming back, and i don't want to kill it 2. react-native start --port=8088 3. update node_modules/react- native/React/React.xcodeproj/project.pbxproj file. Did it. 

Where and which step should i run "react-native start --port=8088" ?

btw, i'm an average engineer, but if i cannot run the very 1st react-native sample in 2 hours, i just cannot see how it can fly, this is very annoying.

3 Answers 3

9

In RN 0.55 you can fix this with:

react-native start --port=1234

and then in a different window:

react-native run-ios --port 1234

Versions:

✗ react-native --version react-native-cli: 2.0.1 react-native: 0.55.4 
Sign up to request clarification or add additional context in comments.

1 Comment

Actually react-native start --port=1234 is not needed. react-native run-ios --port 1234 is enough.
2

Runing React Native Apps on Mac OS when port 8081 is already in use due to another service or APP

For ios emulator

  1. Open Xcode and navigate to Pods -> Development Pods -> React-Core -> Default -> Base -> RCTDefines
  2. Change #define RCT_METRO_PORT 8081 => #define RCT_METRO_PORT 8088 or to desired port number (make sure to change all ocurrencies on that file)
  3. Run npx react-native run-ios --port 8088 (or desired port number and needs to match with the one on RCTDefines file) from the project folder

For Android

  1. Just Runs npx react-native run-android --port=8088 (or desired port #) from the project folder

Comments

1

In yarn managed project in package.json

 "scripts": { ... "ios": "npx react-native run-ios --port 19001 && npx react-native start --port 19001", "android": "npx react-native run-android --port 19001 && npx react-native start --port 19001", } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.