By using AWS re:Post, you agree to the Terms of Use
/Connecting TypeScript backend in EC2 to PostgreSQL RDS/

Connecting TypeScript backend in EC2 to PostgreSQL RDS


I have a TypeScript backend running in a t3.micro EC2 instance. I'm using NPM as the package manager, and TypeORM to seed the database. I have a PostgreSQL database set up in RDS that I'm trying to connect to. In my local dev environment, I didn't have any problem seeding and running the backend and having it connect to RDS. However, in the EC2, it won't finish seeding when running npm run seed which runs the script

ts-node -r tsconfig-paths/register src/seeder/seed.ts

Running npm run migration:run runs the script

yarn run typeorm migration:run

and gives this error:

$ ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run
Error during migration run:
TypeORMError: No connection options were found in any orm configuration files.
    at new TypeORMError (/home/ec2-user/backend/src/error/TypeORMError.ts:7:9)
    at ConnectionOptionsReader.<anonymous> (/home/ec2-user/backend/src/connection/ConnectionOptionsReader.ts:46:19)
    at step (/home/ec2-user/backend/node_modules/typeorm/node_modules/tslib/tslib.js:144:27)
    at (/home/ec2-user/backend/node_modules/typeorm/node_modules/tslib/tslib.js:125:57)
    at fulfilled (/home/ec2-user/backend/node_modules/typeorm/node_modules/tslib/tslib.js:115:62)
error Command failed with exit code 1.
info Visit for documentation about this command.

I'm not too experienced with this, but I've tried deleting node_modules, dist, yarn install, npm install. Any answers as to what I'm missing?

1 Answers


Please check if the EC2 instance security group, if the inbound and outbound rules allow traffic from RDS DB instance.This document can help setup communication between your RDS and EC2 instance [1] [2]

i hear you want to connect to rds postgres from TypeORM. i have found documentation that will help you connect to Postgres from TypeOrm[3]

references [4]

answered 11 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions