N
Neon2y ago
fair-rose

I'm getting an error saying that `"The

I'm getting an error saying that "The server does not support SSL connections when I make a http request to the database, even though I was able to do so until now. I'm using Node.js
9 Replies
rival-black
rival-black2y ago
can you share how are you trying to connect? i've both HTTP, and Pool connection
xenial-black
xenial-black2y ago
require('dotenv').config();

let { PG_HOST, PG_PORT, PG_DATABASE, PG_USER, PG_PASSWORD } = process.env;
const DATABASE_URL = `postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}/${PG_DATABASE}?sslmode=require`


const knex = require('knex')({
client: 'pg',
connection: {
connectionString: DATABASE_URL,
host: PG_HOST,
port: PG_PORT,
user: PG_USER,
database: PG_DATABASE,
password: PG_PASSWORD,
}
});


module.exports = knex;
require('dotenv').config();

let { PG_HOST, PG_PORT, PG_DATABASE, PG_USER, PG_PASSWORD } = process.env;
const DATABASE_URL = `postgresql://${PG_USER}:${PG_PASSWORD}@${PG_HOST}/${PG_DATABASE}?sslmode=require`


const knex = require('knex')({
client: 'pg',
connection: {
connectionString: DATABASE_URL,
host: PG_HOST,
port: PG_PORT,
user: PG_USER,
database: PG_DATABASE,
password: PG_PASSWORD,
}
});


module.exports = knex;
my connection.js file I was copying and pasting the host, database, password, etc in my vs code extension to connect to the database. I'm able to do so but I can't make http calls to it same thing with insomnia, I get the error whenever I try to make a http request
rival-black
rival-black2y ago
am using it with drizzle at the moment (different than yours)
No description
xenial-black
xenial-black2y ago
I think I know why
rival-black
rival-black2y ago
all i need is the connection string, you don't need to creat it youself
xenial-black
xenial-black2y ago
the .env file is empty, but let me check if that's why
rival-black
rival-black2y ago
:chefskiss:
xenial-black
xenial-black2y ago
So, it worked. I apologize for this, and thank you for the support 🙂
rival-black
rival-black2y ago
also, you don't need both, the object and connection string, just pick one:
No description

Did you find this page helpful?