remotion-dev/remotion · error · Error

Studio server port should be a number between 1 and 65535. G

Error message

Studio server port should be a number between 1 and 65535. Got ${port}

What it means

After the type check, `setStudioPort` validates that the port is within the valid TCP range (1-65535). Ports outside that range — including common mistakes like `0`, negative numbers, or 70000 — are rejected with a clear message.

Source

Thrown at packages/cli/src/config/preview-server.ts:23

let studioPort: number | undefined;
let rendererPort: number | undefined;

const validatePort = (port: number | undefined) => {
	if (!['number', 'undefined'].includes(typeof port)) {
		throw new Error(
			`Studio server port should be a number. Got ${typeof port} (${JSON.stringify(
				port,
			)})`,
		);
	}

	if (port === undefined) {
		return;
	}

	if (port < 1 || port > 65535) {
		throw new Error(
			`Studio server port should be a number between 1 and 65535. Got ${port}`,
		);
	}
};

/**
 *
 * @param port
 * @deprecated Use the `setStudioPort` and `setRendererPort` functions instead
 * @returns
 */
export const setPort = (port: number | undefined) => {
	setStudioPort(port);
	setRendererPort(port);
};

export const setStudioPort = (port: number | undefined) => {
	validatePort(port);

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pick a port in 1-65535 (commonly 3000, 8080), or pass `undefined` to let Remotion choose.
  2. If the source is dynamic, clamp or validate before calling.

Example fix

// before
Config.setStudioPort(0);
// after
Config.setStudioPort(undefined);
Defensive patterns

Strategy: validation

Validate before calling

const port = Number(process.env.STUDIO_PORT);
if (!Number.isInteger(port) || port < 1 || port > 65535) {
  throw new Error(`STUDIO_PORT must be an integer in 1..65535, got ${process.env.STUDIO_PORT}`);
}
Config.setStudioPort(port);

Type guard

const isValidPort = (v: number): boolean =>
  Number.isInteger(v) && v >= 1 && v <= 65535;

Prevention

When it happens

Trigger: Calling `Config.setStudioPort(0)`, `setStudioPort(-1)`, `setStudioPort(70000)`, or `setStudioPort(65536)`. Also `setStudioPort(Number('abc'))` which yields `NaN` (NaN comparisons are false, but `NaN < 1` is false so it slips — except NaN is caught by the earlier type check since `typeof NaN === 'number'`; in practice the range check catches 0 and out-of-range integers).

Common situations: Typing a placeholder like `0` meaning 'any port'; mis-typed config (`setStudioPort(800000)`); copy-paste from a URL that includes the path; treating a Unix-only high port (>65535) as valid.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/9759a13650b9eade. Report an issue: GitHub.