GeezerVison is showing github.com — Port is hard coded to 8081 on iOS, Android templates · Issue #9145 · react/react-native
Port is hard coded to 8081 on iOS, Android templates #9145DescriptionThe documentation on working around port conflict issues is no longer valid
https://facebook.github.io/react-native/docs/troubleshooting.html
Mentions the command line and the URL in AppDelegate.m (which has changed to a function call now)
but does not mention that
node_modules/react-native/React/React.xcodeproj/project.pbxproj
has 8081 hard-coded
Also, to be perfectly blunt, telling people to kill their virus scanner is negligent behavior. We need a solution that doesn't involve asking people to turn off safety features their organization mandated that they use. Especially when you have a company name attached to that advice. Reacted by William Perkola, Jacob Patenaude, Nick Colgan, Imran Brown, Ocie Mitchell, Maksym Rusynyk, Samer Murad, uvinw, Lazar M, leon and 13 more Activityhramos commented on Aug 1, 2016 jdmarshall commented on Aug 1, 2016 I can't, because I can't get it to work. Short of searching the entire node_modules directory for instances of 8081 and changing them, because there are new spots that were hard coded after these instructions were written, and there is no obvious way to override them jdmarshall commented on Aug 1, 2016 react-native/local-cli/server/server.js
Takes an override, but at least most of these below seem to ignore it:
react-native/React/Base/RCTBundleURLProvider.m
react-native/Libraries/WebSocket/RCTWebSocketExecutor.m
react-native/React/React.xcodeproj/project.pbxproj
The others I could probably sort out, despite not being an Objective C programmer, but the last one seems to be new and I don't have the foggiest how to pass in the port as a parameter:
react-native/React/React.xcodeproj/project.pbxproj
shellScript = "if nc -w 5 -z localhost 8081 ; then...
perkola commented on Aug 2, 2016 These files below also seem to have port 8081 hard-coded in some places.
react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java
react-native/packager/react-packager/src/Server/__tests__/Server-test.js
react-native/local-cli/util/isPackagerRunning.js
react-native/Libraries/Image/__tests__/resolveAssetSource-test.js
Reacted by Jason Marshall and Nathan de Paz perkola commented on Aug 3, 2016 Does this classify as a bug? Or how do i set a custom port that actually works? Reacted by Alexander Trauzzi perkola commented on Aug 4, 2016 Bump. This seems to be a problem with Android as well. Starting the packager on a different port with react-native start --port 8082 worked on v.0.26.* but no longer works on v.0.30.0. Reacted by Alonso A. Ortega MichaelCereda commented on Oct 31, 2016 This bug should be treated with with high priority, port 8081 is used by some process like McAfee.
Changing the default port should be easy and painless. Reacted by klr, Dheeraj, tanu11, Andrii Chubai and Prithvi Raju Uppalapati satya164 commented on Oct 31, 2016 @MichaelCereda If this is a high priority issue for you, consider sending a PR to fix it. Reacted by Lucas Bento and Leonardo Drici Reacted by Jason Marshall, Jonathan Caouette, Anup Kale, Pipe Work, Snorre Lothar von Gohren Edwin, Matt Davis, Manan Vaghasiya, Jon Lambert, uvinw, Mykhaylo Ryechkin and 33 more Reacted by Alexander Macdonald Reacted by Lucas Bento jdmarshall commented on Oct 31, 2016 I have some deep philosophical problems with suggesting that a feature that mostly affects new users should be fixed in a PR by those new users.
By all means, let's get esoteric feature requests to file their own PRs. But it comes off as flippant when it's a feature brand new users run into before they even decide if they want to be part of the ecosystem.
(It's especially grating when that bug is a port conflict. Is this 1996 or 2016?) Reacted by Matt Davis, Jonathan Cardoso, Samer Murad, Nancy D'Aquino, ryan dushane, Will Bamford, Adam Weber, Matheus Matos, Rafael Roman, Nicolas Kerdelhué and 12 more MichaelCereda commented on Nov 1, 2016 By now the fastest solution is to kill the process (in my case McAfee) and face the web like a real man.
I always find interesting those type of comments because I have hard time understand if they are a sort of life coaching aimed at the self improvement or mere trolling.
As @jdmarshall said, I think that is an high priority fix because it discourages new users to adopt react-native that is a framework that I personally love.
Submitting a PR it's possible but at the same time would require centralize the port number under one configuration file., the problem with this approach is that RN currently uses 3 different environments that should in many ways be independent from external files (that's why the port number has always been hard-coded in at least 2 places).
The only problem is my opinion that the port RN is using is the 8081 that is one of the most common ever and the risk of conflict is high.
I'll try to find a solution but suggestions from the team will be highly appreciated. nhunzaker commented on Feb 24, 2019 I took a stab at this in for Android with #23616 grabbou commented on Mar 19, 2019 Closing since the original issue is already fixed (you can easily change the port on iOS by setting environmental variables).
Given the complexity of the native build systems, it's not as easy as it is in JavaScript to just change or auto-detect the port.
Looks like the Android support is being added thanks to @nhunzaker. grisaitis commented on May 30, 2019 Helpful tip: if you encounter the error message 'No bundle URL present' in your iOS emulator, then clean your build folder (ios/build/) and maybe node_modules/ as well. I think the build needs to be completely cleaned and redone any time the port value is changed. grisaitis commented on May 30, 2019 Should these environment variables be documented somewhere? I don't see anything in docs or repo READMEs. AdamMarcus commented on Oct 12, 2019 Just wanted to throw out that I am hitting this still while just trying to get through my first react-native demo (in Windows/Android). TempusFugitful commented on Nov 11, 2019
Just wanted to throw out that I am hitting this still while just trying to get through my first react-native demo (in Windows/Android).
I too am still seeing this issue. The "--port" option is seemingly ignored by the "react-native run-ios --port 9000" command, as the Metro Bundler still starts up in port 8081. The "react-native start --port 9000" command does not ignore the "--port" option. So while I can force the metro bundler to open up on a port other than 8081, it does not do so when launched as part of the overall "react-native run-ios" command.
This still doesn't solve the problem as I then have a react app installed on iOS that expects the default port, while the metro bundler is listening on the new port (if it is started by itself with the "react-native start --port 9000" command). Reacted by Erika Pierre and Harshit Mahapatra locked as resolved and limited conversation to collaborators on Mar 20, 2020
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|