By MSadiq
Backend Engineer
I know this seems like a redundant question, but I’ve checked others like it and non of them helped.
I am trying to seed my DO managed Postgres DB with some data, while the seeder works perfectly fine in development I kept getting this timeout error when trying to do the same in production. Below is what my config looks like with nestJs and typeorm
{
type: 'postgres',
host: DB_HOST,
port: +DB_PORT,
username: DB_USERNAME,
password: DB_PASSWORD,
database: DB_NAME,
entities: [__dirname + '/../**/*.entity.{js,ts}'],
ssl:
process.env.NODE_ENV === 'prod'
? {
requestCert: true,
rejectUnauthorized: true,
ca: fs.readFileSync(`${process.cwd()}/ca-certificate.crt`).toString(),
}
: undefined,
autoLoadEntities: true,
}
Any form of help is welcome, thank you
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
👋 @msadiq
Hmm, let me see if I can help. Attached DB’s bind variables (eg. the env vars that are set like DB_HOST=${db.HOSTNAME} are not available during build time. If you’r trying to run this script as part of the app build that is likely the culprit. I would recommend running this seed as part of your application startup or as a predeploy job.
If the above is not the case, then try outputting some of your env vars to console during app startup and verify they are correct.
Hope this helps!
Hi @msadiq,
First, check the following article:
https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/#databases
Try to define the variables as suggested there ^
Additionally, Have you check out Trusted sources? (click on your app and click on the Settings tab) You could have restricted access to database cluster.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.