FlowiseAI/Flowise · error · Error

Invalid port number

Error message

Invalid port number

What it means

MySQLSaver.getDataSource hard-rejects port 5432 (the Postgres default) to stop a MySQL saver from pointing at a Postgres endpoint. Note the guard is a strict numeric === 5432; a string '5432' would bypass it.

Source

Thrown at packages/components/nodes/memory/AgentMemory/MySQLAgentMemory/mysqlSaver.ts:41

        // Trim and normalize case, turn whitespace into underscores
        tableName = tableName.trim().toLowerCase().replace(/\s+/g, '_')

        // Validate using a regex (alphanumeric and underscores only)
        if (!/^[a-zA-Z0-9_]+$/.test(tableName)) {
            throw new Error('Invalid table name')
        }

        return tableName
    }

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

    private async setup(dataSource: DataSource): Promise<void> {
        if (this.isSetup) return

        try {
            const queryRunner = dataSource.createQueryRunner()
            const tableName = this.sanitizeTableName(this.tableName)
            await queryRunner.manager.query(`
                CREATE TABLE IF NOT EXISTS ${tableName} (
                    thread_id VARCHAR(255) NOT NULL,
                    checkpoint_id VARCHAR(255) NOT NULL,
                    parent_id VARCHAR(255),
                    checkpoint BLOB,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Set the MySQL port (default 3306) on the memory node.
  2. Use the Postgres Agent Memory node if the target is actually Postgres.
  3. Ensure port is supplied as a number so the guard evaluates correctly.

Example fix

// before
datasourceOptions: { type:'mysql', host, port:5432, ... }
// after
datasourceOptions: { type:'mysql', host, port:3306, ... }
Defensive patterns

Strategy: validation

Validate before calling

function assertMysqlPort(port: unknown): number {
  const p = Number(port)
  if (!Number.isInteger(p) || p <= 0) throw new Error('Port must be a positive integer')
  if (p === 5432) throw new Error('Port 5432 is Postgres; use the Postgres node or set a MySQL port (e.g. 3306)')
  return p
}
datasourceOptions.port = assertMysqlPort(datasourceOptions.port)

Type guard

function isMysqlPort(port: unknown): boolean {
  const p = Number(port); return Number.isInteger(p) && p > 0 && p !== 5432
}

Try / catch

try {
  await saver.getTuple(config)
} catch (e) {
  if (/Invalid port number/.test((e as Error).message)) {
    // guide user to correct the port; do not retry
  }
  throw e
}

Prevention

When it happens

Trigger: MySQL memory node configured with port 5432, typically because Postgres connection settings were copied into the MySQL node.

Common situations: Cross-DB misconfiguration; default PG port leftover from a template; copy-paste of a Postgres connection string.

Related errors


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