Describe the problem/error/question
Attempting to run n8n on ECS Fargate, however, when the container launches, the logs show the following:
“There was an error initializing DB”
I have a very basic setup in my CDK stack. Not sure if it will be helpful, but here’s what I have so far:
// RDS PostgreSQL (must be defined before it's referenced)
const db = new rds.DatabaseInstance(this, 'N8nDb', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_15_7 }),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T4G, ec2.InstanceSize.MICRO),
vpc,
vpcSubnets: { subnetGroupName: 'DbSubnet' },
securityGroups: [dbSG],
credentials: rds.Credentials.fromPassword('n8n', cdk.SecretValue.unsafePlainText('myn8npasswordhere')),
databaseName: 'n8n',
publiclyAccessible: false,
multiAz: false,
allocatedStorage: 20,
maxAllocatedStorage: 100,
removalPolicy: cdk.RemovalPolicy.DESTROY,
deletionProtection: false,
});
taskDef.addContainer('N8nContainer', {
image: ecs.ContainerImage.fromRegistry('n8nio/n8n'),
environment: {
N8N_BASIC_AUTH_ACTIVE: 'true',
N8N_BASIC_AUTH_USER: n8nAuthSecret.secretValueFromJson('user').unsafeUnwrap(),
N8N_BASIC_AUTH_PASSWORD: n8nAuthSecret.secretValueFromJson('password').unsafeUnwrap(),
N8N_DIAGNOSTICS_ENABLED: 'false',
N8N_LOG_LEVEL: 'debug',
DB_TYPE: 'postgresdb',
DB_POSTGRESDB_HOST: db.dbInstanceEndpointAddress,
DB_POSTGRESDB_PORT: '5432',
DB_POSTGRESDB_DATABASE: 'n8n',
DB_POSTGRESDB_USER: 'n8n',
DB_POSTGRESDB_PASSWORD: 'myn8npassword',
DB_POSTGRESDB_SSL_ENABLED: 'true',
What is the error message (if any)?
“There was an error initializing DB”
Please share your workflow
NA
Share the output returned by the last node
Information on your n8n setup
- n8n version: latest
- Database (default: SQLite): AWS RDS - PostgreSQL
- n8n EXECUTIONS_PROCESS setting (default: own, main): NA
- Running n8n via (Docker, npm, n8n cloud, desktop app): AWS ECS Fargate (Docker)
- Operating system: Amazon Linux 2
I added the code I have for the DB setup above.