Report this

What is the reason for this report?

How to fix Error: connect ETIMEDOUT 138.68.132.125:25060 In Postgresql

Posted on November 2, 2022
MSadiq

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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

👋 @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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Dark mode is coming soon.