{"record":{"id":"476cc6104b338751","repo":"remotion-dev/remotion","slug":"studio-server-port-should-be-a-number-got-typeo","errorCode":null,"errorMessage":"Studio server port should be a number. Got ${typeof port} (${JSON.stringify(port)})","messagePattern":"Studio server port should be a number\\. Got (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/config/preview-server.ts","lineNumber":11,"sourceCode":"import {BrowserSafeApis} from '@remotion/renderer/client';\nimport {parsedCli} from '../parsed-cli';\n\nconst {portOption} = BrowserSafeApis.options;\n\nlet studioPort: number | undefined;\nlet rendererPort: number | undefined;\n\nconst validatePort = (port: number | undefined) => {\n\tif (!['number', 'undefined'].includes(typeof port)) {\n\t\tthrow new Error(\n\t\t\t`Studio server port should be a number. Got ${typeof port} (${JSON.stringify(\n\t\t\t\tport,\n\t\t\t)})`,\n\t\t);\n\t}\n\n\tif (port === undefined) {\n\t\treturn;\n\t}\n\n\tif (port < 1 || port > 65535) {\n\t\tthrow new Error(\n\t\t\t`Studio server port should be a number between 1 and 65535. Got ${port}`,\n\t\t);\n\t}\n};\n\n/**","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/cli/src/config/preview-server.ts#L1-L29","documentation":"`setStudioPort` / `setPort` (deprecated alias) in preview-server.ts validate that the supplied port is `number` or `undefined`. Any other JS type (string from env, null, object) throws an Error echoing the actual type and JSON value.","triggerScenarios":"Calling `Config.setStudioPort(process.env.STUDIO_PORT)` where the env var is a string; `setStudioPort('3000')`; `setStudioPort(null)`.","commonSituations":"Reading the port from `process.env` (always string); parsing a config file where the value is quoted; receiving the port over IPC/JSON as a string.","solutions":["Parse the env value to a number: `Config.setStudioPort(Number(process.env.STUDIO_PORT))`.","Pass `undefined` explicitly when you want Remotion to pick a port."],"exampleFix":"// before\nConfig.setStudioPort(process.env.STUDIO_PORT);\n// after\nConfig.setStudioPort(\n  process.env.STUDIO_PORT ? Number(process.env.STUDIO_PORT) : undefined,\n);","handlingStrategy":"type-guard","validationCode":"const raw = process.env.STUDIO_PORT;\nconst port = raw === undefined ? undefined : Number(raw);\nif (port !== undefined && Number.isNaN(port)) {\n  throw new Error(`STUDIO_PORT must be numeric, got ${raw}`);\n}\nConfig.setStudioPort(port);","typeGuard":"const isPortInput = (v: unknown): v is number | undefined =>\n  v === undefined || (typeof v === 'number' && Number.isFinite(v));","tryCatchPattern":null,"preventionTips":["Convert env strings with `Number()` and check `Number.isNaN`.","Pass `undefined` rather than a string when you want Remotion to choose."],"tags":["config","validation","studio","port","typescript"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}