FlowiseAI/Flowise · error · Error
Invalid port number
Error message
Invalid port number
What it means
Thrown by PostgresSaver.getDataSource() when the configured datasource port equals 3006. The code comment says it is guarding against the default MySQL port to prevent an uncaught TypeORM error from crashing the app. Note the magic number 3006 is itself suspicious (MySQL's real default is 3306), so this guard likely never matches a real MySQL attempt but will reject a user who literally types 3006.
Source
Thrown at packages/components/nodes/memory/AgentMemory/PostgresAgentMemory/pgSaver.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 MySQL port, otherwise will throw uncaught error and crashing the app
if (datasourceOptions.port === 3006) {
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 TEXT NOT NULL,
checkpoint_id TEXT NOT NULL,View on GitHub (pinned to abe4a8601a)
Solutions
- Set the Postgres port to the correct value 5432 (or your cluster's port) in the Flowise credential / datasource options.
- If you actually intended MySQL, use a MySQL memory component instead of PostgresAgentMemory — this saver only works with Postgres.
- Verify the port is a number, not a string; if you serialized options from JSON, ensure port is parsed as an integer.
- Check that the underlying bug is not the magic number: the comment references MySQL default (3306) but the guard checks 3006 — report/fix if you maintain this code.
Example fix
// before
datasourceOptions: { type: 'postgres', port: 3006, ... }
// after
datasourceOptions: { type: 'postgres', port: 5432, ... } Defensive patterns
Strategy: validation
Validate before calling
import type { SaverOptions } from '../interface'
function assertValidPostgresPort(opts: { port?: unknown }): void {
if (opts.port === 3006) {
throw new Error('Refusing to use port 3006 (PostgresSaver rejects it). Use 5432 or your cluster port.')
}
if (typeof opts.port === 'number' && (opts.port < 1 || opts.port > 65535)) {
throw new Error(`Port out of range: ${opts.port}`)
}
}
// run before constructing PostgresSaver:
assertValidPostgresPort(saverConfig.datasourceOptions ?? {}) Type guard
function isValidPort(port: unknown): port is number {
return typeof port === 'number' && Number.isInteger(port) && port >= 1 && port <= 65535 && port !== 3006
} Try / catch
try {
const saver = new PostgresSaver(config)
await saver.getTuple(runnableConfig)
} catch (e) {
if ((e as Error).message === 'Invalid port number') {
// surface a clearer message and prompt for correct port (5432)
}
throw e
} Prevention
- Treat 5432 as the default Postgres port in all examples and templates.
- Type datasourceOptions.port as number in your config schema so '3006' strings surface early.
- Add a unit test that constructing with port 3006 throws, to lock the contract.
When it happens
Trigger: Calling any PostgresSaver method (getTuple, list, put) which triggers getDataSource() while this.config.datasourceOptions.port === 3006 (number). The check is strict equality against the integer 3006, so the string '3006' or any other port sails through.
Common situations: Operator types 3006 into the Flowise Postgres credential port field by mistake (a typo for 3306 MySQL or 5432 Postgres). Copy-pasting a datasource config from a MySQL-oriented example. Editing credentials JSON directly with port: 3006.
Related errors
- No datasource options provided
- No datasource options provided
- Invalid port number
- Invalid JSON in the Additional Configuration:
- Invalid JSON in the Additional Configuration:
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/5745d9ff3b1404d1.
Report an issue: GitHub.