n8n-io/n8n · error

Invalid instance URL.

Error message

Invalid instance URL.

What it means

Thrown by assertConnectOriginAllowed when `new URL(url)` raises — the supplied instance URL is not parseable as a URL (after trimming a trailing slash). This runs before any network call, so it guards the deep-link / IPC connect path against malformed input. The check exists in the local gateway main process.

Source

Thrown at packages/@n8n/local-gateway/src/main/connect-origin.ts:12

import { isOriginAllowed } from '@n8n/computer-use/config';

/**
 * Throws if the normalized instance URL's origin is not allowed by the configured patterns.
 * Call before constructing GatewayClient (deep link / IPC connect).
 */
export function assertConnectOriginAllowed(url: string, allowedOriginPatterns: string[]): void {
	let origin: string;
	try {
		origin = new URL(url.replace(/\/$/, '')).origin;
	} catch {
		throw new Error('Invalid instance URL.');
	}
	if (!isOriginAllowed(origin, allowedOriginPatterns)) {
		throw new Error(
			'This instance URL is not in your allowed origins list. Open Settings and add its origin, or use a deeplink from your trusted n8n.',
		);
	}
}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Ensure the URL includes a protocol: 'https://instance.example.com' not 'instance.example.com'.
  2. Validate and encode the URL before opening the deep link.
  3. If building the deep link programmatically, construct it with `new URL(...).toString()` on the origin side so it is always well-formed.

Example fix

// before
assertConnectOriginAllowed(userInput, allowed);

// after — validate/normalize first
function safeAssert(url: string, allowed: string[]) {
  const normalized = /^https?:\/\//.test(url) ? url : `https://${url}`;
  assertConnectOriginAllowed(normalized, allowed);
}
Defensive patterns

Strategy: validation

Validate before calling

function isValidInstanceUrl(url: string): boolean {
  try {
    // mirror the internal normalization
    new URL(url.replace(/\/$/, ''));
    return true;
  } catch {
    return false;
  }
}

Type guard

function isParseableUrl(url: string): boolean {
  try { new URL(url); return true; } catch { return false; }
}

Prevention

When it happens

Trigger: Calling assertConnectOriginAllowed(url, patterns) where url is empty, missing a protocol (e.g. 'example.com'), contains invalid URL characters, or is not a string that new URL() can construct from. Triggered when a deep link or IPC connect payload carries a malformed URL field.

Common situations: Deep link was hand-edited or copy-pasted with the protocol stripped; an IPC message from a renderer with a missing/empty url field; a URL with spaces or non-ASCII characters that wasn't encoded; passing a bare hostname without https://.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/d8ad320dce16a4f7. Report an issue: GitHub.