React-native: App still runs in port 8081 even after changing AppDelegate.m

Created on 10 Oct 2015  Â·  12Comments  Â·  Source: facebook/react-native

As per instructions to change port I changed AppDelegate.m port:
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8082/index.ios.bundle?platform=ios&dev=true"];

But when running I still get the app trying to connect to 8081

Note, I am running the xcode project in the UIExplorer demo in the RN repo.

Locked

Most helpful comment

Hello there,

I have fixed this issue by the step below:
if you installed McAfee antivirus, the default port of McAfee log is 8081. You should manual change the port of your react native server

Step 1: go to node_modules\react-native\local-cli\server\server.js and change the port 8081 to 8088

const args = parseCommandLine([{
command: 'port',
default: 8088,
type: 'string',
}

Step 2: Create an "assets" folder under "android/app/src/main"

Step 3: in node.js run "react-native start" and navigate to the url "http://localhost:8088/index.android.bundle?platform=android"

Step 4: save the bundle to assets folder and you are all set. in node.js run "react-native run-android" to view the result

Regards,

Hai Tang

All 12 comments

Is this the same issue as 1429? I can't get it to work either because I have something already running on 8081.

It appears that the instructions are incomplete - I got it to work after doing a global find/replace from 8081 to a new number (in my case 8082), INCLUDING in the react-native npm folder. That last bit was what got me for a while until a coworker suggested I do the find/replace there as well.

This should be a setting that can be easily configured, but right now 8081 is hardcoded in a bunch of places, it seems.

I've posted this on product pains so it would be great if you could upvote it there and show the react-native team that this is an important feature https://productpains.com/post/react-native/allow-packager-port-to-be-configurable-change-from-8081/

I voted. Thanks!

Closing in favour of #1429

Hello there,

I have fixed this issue by the step below:
if you installed McAfee antivirus, the default port of McAfee log is 8081. You should manual change the port of your react native server

Step 1: go to node_modules\react-native\local-cli\server\server.js and change the port 8081 to 8088

const args = parseCommandLine([{
command: 'port',
default: 8088,
type: 'string',
}

Step 2: Create an "assets" folder under "android/app/src/main"

Step 3: in node.js run "react-native start" and navigate to the url "http://localhost:8088/index.android.bundle?platform=android"

Step 4: save the bundle to assets folder and you are all set. in node.js run "react-native run-android" to view the result

Regards,

Hai Tang

Is this issue fixed now? I am still not able to make it work in my office laptop where McAfee agent is running at port 8081. I am still seeing 8081 is hardcoded in lot of places in react native code in latest build.

@haitang3009 I have the same problem with @abhranilnaha ,Now I can run my app and can view my content 'hello world',but when I am double-click the key ‘r’ to refresh,a red screen show:"The development server returned response error code:403;URL:http://10.0.3.2:8081/Index.android.bundle?platform=android&dev=true&hot=false&minify=false……"
how could I solve the problem?

@codepandy Did you get your problem resolve? I have the same problem now!

@jayhuang75 sorry,I didn't solve the problem.

This is kinda old, but I'm still having this conflict with McAfee, any update on this?

Was this page helpful?
0 / 5 - 0 ratings