I’ve been trying for a week without success. I configured CA on my connection and it still doesn’t work. I did not include any reliable source to leave public access.
The error: error: no pg_hba.conf entry for host “**7.15.139.203”, user “xxxx”, database “xxx”, no encryption
Has anyone been through this?
const dataSource = **new** DataSource({
type: "postgres",
host: process.env.DATABASE_HOST,
port: parseInt(process.env.DATABASE_PORT, 10) || 5432,
username: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_NAME,
entities: [xxxx, xxxxx],
synchronize: false,
dropSchema: false,
logging: false,
ssl: {
ca: process.env.CA,
enableTrace: true,
rejectUnauthorized: true
}
});
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!
Hi there,
Are you using a managed Postgres database cluster? If so, you might also want to try setting rejectUnauthorized: false
just to test if it’s an SSL-related issue.
https://docs.digitalocean.com/products/databases/postgresql/how-to/connect/
Also, another thing that you could try is to use Pool
from pg
instead:
export const pool = new Pool({
user: process.env.DB_USERNAME,
host: process.env.DB_HOSTNAME,
database: process.env.DATABASE,
password: process.env.DB_PASSWORD,
port: Number(process.env.DB_PORT),
ssl: {
rejectUnauthorized: true,
ca: process.env.CA_CERT,
},
})
Let me know how it goes.
- Bobby
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.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.