Unable to change devToolsPort default value

Hi there!

I need a way to change the default port of the expo dev tools port variable “devToolsPort” : 19002 from the packager-info.json file.

For example in order to change the port of the packager I just have to add this line of code in app.json:

   "packagerOpts": {
      "port": 8081

But I can’t find the equivalent parameter in the expo app.json documentation for the dev tools port doc

My goal is to be able to debug at port 8080. Since I am using Amazon cloud9. They only let you use ports 8080, 8081, 8082 doc.

I currently have the packager port configured in 8081 and it is fine. I need the same for the debugging tool.

Thank you!

SDK Version: 36


packager-info.json lives in the .expo directory inside your project. Unfortunately it seems this is written when you run expo start, so it doesn’t seem possible to specify the port.

There are a couple of things you could do to work around this. e.g. fork expo-cli and change the devToolsPort. If you find a good way to do it you might even want to contribute the change back to Expo.

I think something like this might work:

diff --git packages/dev-tools/server/DevToolsServer.js packages/dev-tools/server/DevToolsServer.js
index e0d49a3b..4da83a9a 100644
--- packages/dev-tools/server/DevToolsServer.js
+++ packages/dev-tools/server/DevToolsServer.js
@@ -48,8 +48,8 @@ export async function createAuthenticationContextAsync({ port }) {
-export async function startAsync(projectDir) {
-  const port = await freeportAsync(19002, { hostnames: [null, 'localhost'] });
+export async function startAsync(projectDir, desiredPort) {
+  const port = await freeportAsync(desiredPort, { hostnames: [null, 'localhost'] });
   const server = express();
   const authenticationContext = await createAuthenticationContextAsync({ port });
diff --git packages/expo-cli/src/commands/start.js packages/expo-cli/src/commands/start.js
index 4d4a2993..5727e6c8 100644
--- packages/expo-cli/src/commands/start.js
+++ packages/expo-cli/src/commands/start.js
@@ -248,6 +248,8 @@ export default (program: any) => {
     .option('--max-workers [num]', 'Maximum number of tasks to allow Metro to spawn.')
     .option('--dev', 'Turn development mode on')
     .option('--no-dev', 'Turn development mode off')
+    .option('--dev-tools-port <port>', 'Specify the preferred port for the dev tools server',
+      (value, dummyPrevious) => parseInt(value), 19002)
     .option('--minify', 'Minify code')
     .option('--no-minify', 'Do not minify code')
     .option('--https', 'To start webpack with https protocol')

Otherwise you could set up something crude like inetd and netcat that just forwards connections from port 8080 to port 19002. Or something more sophisticated like a proper HTTP proxy server (e.g. nginx, Apache, HAProxy, Squid).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.