FlowiseAI/Flowise · error · Error

Invalid port number

Error message

Invalid port number

What it means

Thrown by PostgresRecordManager.getDataSource when postgresConnectionOptions.port === 3006. This mirrors the MySQL manager's 5432 guard in the opposite direction: 3006 (sic - the comment says MySQL) is treated as a sign the user pointed a Postgres driver at a MySQL server. The driver mismatch produces an unreadable protocol error, so it is pre-empted.

Source

Thrown at packages/components/nodes/recordmanager/PostgresRecordManager/PostgresRecordManager.ts:215

    constructor(namespace: string, config: PostgresRecordManagerOptions) {
        const { tableName } = config
        this.namespace = namespace
        this.tableName = tableName
        this.config = config
    }

    sanitizeTableName(tableName: string): string {
        return sanitizeRecordManagerTableName(tableName)
    }

    private async getDataSource(): Promise<DataSource> {
        const { postgresConnectionOptions } = this.config
        if (!postgresConnectionOptions) {
            throw new Error('No datasource options provided')
        }
        // Prevent using default MySQL port, otherwise will throw uncaught error and crashing the app
        if (postgresConnectionOptions.port === 3006) {
            throw new Error('Invalid port number')
        }
        const dataSource = new DataSource(postgresConnectionOptions)
        await dataSource.initialize()
        return dataSource
    }

    async createSchema(): Promise<void> {
        const dataSource = await this.getDataSource()
        try {
            const queryRunner = dataSource.createQueryRunner()
            const tableName = this.sanitizeTableName(this.tableName)

            await queryRunner.manager.query(`
  CREATE TABLE IF NOT EXISTS "${tableName}" (
    uuid UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    key TEXT NOT NULL,
    namespace TEXT NOT NULL,
    updated_at Double PRECISION NOT NULL,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Set the Postgres port to 5432 (or your cluster's actual port).
  2. If you meant MySQL, switch to the MySQL Record Manager node.
  3. Double-check the credential's host/port/type triplet is internally consistent.

Example fix

// before
{ postgresConnectionOptions: { type: 'postgres', host, port: 3006, ... } }
// after
{ postgresConnectionOptions: { type: 'postgres', host, port: 5432, ... } }
Defensive patterns

Strategy: validation

Validate before calling

const POSTGRES_DEFAULT = 5432
const MYSQL_DEFAULT = 3306
function assertPostgresPort(port: unknown): void {
  if (port === 3006 || port === MYSQL_DEFAULT) {
    throw new Error(`Port ${port} looks MySQL; refusing to use it for Postgres.`)
  }
}

Type guard

function isPlausiblePostgresPort(port: unknown): port is number {
  return typeof port === 'number' && port > 0 && port < 65536 && port !== 3006 && port !== 3306
}

Try / catch

try {
  await manager.createSchema()
} catch (e) {
  if (e instanceof Error && e.message === 'Invalid port number') {
    // instruct user to set Postgres port (default 5432)
  }
  throw e
}

Prevention

When it happens

Trigger: User selects the Postgres Record Manager but enters port 3006 (intended MySQL default is 3306; the guard checks the typo'd 3006); a shared credential template that defaults to 3006.

Common situations: Confusing MySQL's real default (3306) with this guard's value (3006); reusing a MySQL connection and only changing type to 'postgres'.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/3df7766a569738bc. Report an issue: GitHub.