I'm trying to get up and running with React Native and I am seeing the message below in Xcode:
Port 8081 already in use, packager is either not running or not running correctly
Command /bin/sh failed with exit code 2
I went to the React Native troubleshooting page and tried to kill the port 8081 processes, but I'm still getting the same issue.
Here is a screenshot of what I am seeing in Xcode:
Any help would be fully appreciated.
With the help of other people's answers. I tried the following steps. It worked for me and hopefully for others. It only works for iOS. Let’s say we want to change the 8081 port to 8999 port.
First, Open Xcode.
Look at Project navigator(left) In [ProjectName]/[ProjectName]/AppDelegate.m:
Change
http://localhost:8081/index.ios.bundle?platform=ios&dev=true
to
http://localhost:8999/index.ios.bundle?platform=ios&dev=true
In Project navigator(left) [ProjectName]/ Libraries:
Click “React.xcodeproj”. On main panel, click “Build Phases” tag.
Expand “Run Script”, delete it with the cross.
In Project navigator(left) [ProjectName] / Libraries / RCTWebSocket.xcodeproj / RCTWebSocketExecutor.m : Search 8081 and replace it with 8999
Second open Finder
In the project root, open “package.json” :
Change the “script” attribute to :
{...
"start": "node_modules/react-native/packager/packager.sh --port=8999"
...
}
Then Open terminal
$cd to project root :
$ npm start
Cool! Then
Go back to Xcode and click the play button.
Cross your fingers.
Be Patient. There will be a blank in the client.
You can see it is doing building on the backend(terminal will log it).