n8n-io/n8n · error · NodeOperationError

Error: ${error.message}

Error message

Error: ${error.message}

What it means

Catch-all NodeOperationError in the MongoDB Atlas vector store's `getCollections` load-options function. It runs when the user opens the collection dropdown in the UI and any step — `createMongoClient`, `getDatabase`, or `db.listCollections().toArray()` — throws. The original error message is appended.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts:210

/**
 * Get all the collection in the database.
 * @param this The load options context.
 * @returns The list of collections.
 */
export async function getCollections(this: ILoadOptionsFunctions) {
	const client = await createMongoClient(this, this.getNode().typeVersion);
	try {
		const db = await getDatabase(this, client);
		const collections = await db.listCollections().toArray();
		const results = collections.map((collection) => ({
			name: collection.name,
			value: collection.name,
		}));

		return { results };
	} catch (error) {
		throw new NodeOperationError(this.getNode(), `Error: ${error.message}`);
	} finally {
		void client.close().catch(() => {});
	}
}

/**
 * Get a parameter from the context.
 * @param key - The key of the parameter.
 * @param context - The context.
 * @param itemIndex - The index.
 * @returns The value.
 */
export function getParameter(key: string, context: IFunctionsContext, itemIndex: number): string {
	const value = context.getNodeParameter(key, itemIndex, '', {
		extractValue: true,
	}) as string;
	if (typeof value !== 'string') {
		throw new NodeOperationError(context.getNode(), `Parameter ${key} must be a string`);

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. In Atlas, add the n8n host's public IP to Network Access (or allow `0.0.0.0/0` for testing).
  2. Confirm the cluster is not paused and the connection string is correct.
  3. Verify the database user has at least `read` on the target database.
  4. Re-enter the password in the n8n credential if it was recently rotated.

Example fix

// before
} catch (error) {
  throw new NodeOperationError(this.getNode(), `Error: ${error.message}`);
} finally {
  void client.close().catch(() => {});
}

// after: classify the common auth/network cases for the user
} catch (error) {
  const msg = error instanceof Error ? error.message : String(error);
  const hint = /authentication failed/i.test(msg)
    ? 'Check the database user and password in Atlas.'
    : /ENOTFOUND|ETIMEDOUT|ECONNREFUSED/.test(msg)
      ? 'Check the connection string and Atlas Network Access list.'
      : 'See the Atlas cluster logs for details.';
  throw new NodeOperationError(this.getNode(), `Error: ${msg}`, { description: hint });
} finally {
  void client.close().catch(() => {});
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate Atlas reachability and IP allow-listing before the workflow runs.
async function assertAtlasReachable(uri: string): Promise<void> {
  const client = new MongoClient(uri, { serverSelectionTimeoutMS: 5000 });
  try { await client.db().admin().ping(); } finally { await client.close().catch(() => {}); }
}

Type guard

function classifyMongoError(error: unknown): 'auth' | 'network' | 'unknown' {
  if (!(error instanceof Error)) return 'unknown';
  const m = error.message;
  if (/authentication failed|bad auth/i.test(m)) return 'auth';
  if (/ENOTFOUND|ETIMEDOUT|ECONNREFUSED/.test(m)) return 'network';
  return 'unknown';
}

Try / catch

try {
  const db = await getDatabase(this, client);
  return { results: (await db.listCollections().toArray()).map((c) => ({ name: c.name, value: c.name })) };
} catch (error) {
  const bucket = classifyMongoError(error);
  throw new NodeOperationError(this.getNode(), `Error: ${(error as Error).message}`, {
    description: bucket === 'auth' ? 'Check the database user and password.'
      : bucket === 'network' ? 'Check the connection string and Atlas Network Access list.'
      : 'See Atlas cluster logs.',
  });
} finally {
  void client.close().catch(() => {});
}

Prevention

When it happens

Trigger: Listing collections against a MongoDB Atlas cluster that is unreachable, paused, or whose connection string has the wrong password; the cluster's network access list does not include the n8n host IP; a long-running listCollections call timing out.

Common situations: Atlas M0 free tier paused or hibernating; IP not in the Atlas allow-list; password rotated in Atlas but n8n credential not updated; SRV connection string with a typo; user lacks `listCollections` privilege.

Related errors


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