Drizzle with self hosted supabase not working

Hello, I created a self hosted instance of supabase on my machine. I am also using nextjs. Because of that I need to be using neon driver to connect to supabase instance. This is how I create connection
import { Pool } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-serverless';

const connectionString = env.DATABASE_URL;
const pool = new Pool({ connectionString });
export const db = drizzle(pool, { schema: schema, logger: false });
import { Pool } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-serverless';

const connectionString = env.DATABASE_URL;
const pool = new Pool({ connectionString });
export const db = drizzle(pool, { schema: schema, logger: false });
I have my instance hosted on machine 192.168.50.88 Now when I try to push newly generated migration I am getting
[⣷] Pulling schema from database...ErrorEvent {
[Symbol(kTarget)]: _WebSocket {
_events: [Object: null prototype] {
error: [Function],
message: [Function],
close: [Function],
open: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'arraybuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: <Buffer >,
_closeTimer: null,
_extensions: {},
_paused: false,
_protocol: '',
_readyState: 3,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_autoPong: true,
_url: 'wss://192.168.50.88/v2',
_req: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
[Symbol(kType)]: 'error',
[Symbol(kError)]: Error: self-signed certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
at TLSSocket.emit (node:events:518:28)
at TLSSocket._finishInit (node:_tls_wrap:1085:8)
at ssl.onhandshakedone (node:_tls_wrap:871:12)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
},
[Symbol(kMessage)]: 'self-signed certificate'
}
[⣷] Pulling schema from database...ErrorEvent {
[Symbol(kTarget)]: _WebSocket {
_events: [Object: null prototype] {
error: [Function],
message: [Function],
close: [Function],
open: [Function]
},
_eventsCount: 4,
_maxListeners: undefined,
_binaryType: 'arraybuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: <Buffer >,
_closeTimer: null,
_extensions: {},
_paused: false,
_protocol: '',
_readyState: 3,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_autoPong: true,
_url: 'wss://192.168.50.88/v2',
_req: null,
[Symbol(shapeMode)]: false,
[Symbol(kCapture)]: false
},
[Symbol(kType)]: 'error',
[Symbol(kError)]: Error: self-signed certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
at TLSSocket.emit (node:events:518:28)
at TLSSocket._finishInit (node:_tls_wrap:1085:8)
at ssl.onhandshakedone (node:_tls_wrap:871:12)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
},
[Symbol(kMessage)]: 'self-signed certificate'
}
my connection string is DATABASE_URL=postgres://postgres.<my password>@192.168.50.88:5432/postgres
4 Replies
pacto
pactoOP6mo ago
Same config works just fine with official supabase instance. How can I disable these ssl checks when pushing migrations? Also how can I specify a url when making migrations? b
KamKom
KamKom6mo ago
Hi Pacto, I'm also self-hosting supabase on coolify (docker based) and tring to access my db from the outside in a nextjs app with drizzle. I'm getting confused about the documentation. This page: https://orm.drizzle.team/learn/tutorials/drizzle-with-supabase says connection pooling is mandatory BUT here: https://orm.drizzle.team/docs/get-started-postgresql#supabase it says connection pooling is optional. I dont want to use pooling because I'll have to figure out a separated pooler etc.. is connection pooler mandatory or not to use with drizzle orm ? As a self-hosted instance of supabase on a vps is NOT serverless, I don't see with it should be mandatory rather than direct connection.
Drizzle ORM - Drizzle with Supabase Database
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Drizzle ORM - PostgreSQL
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
pacto
pactoOP6mo ago
Well, It used to work for me with direct connection in Nextjs without an issue, but then I started checking if user is authenticated in my middleware which then bricked because of postgres not supporting some functionality. What is your self hosted setup? Did you manage to connect? I am hosting on my own server, but also tried on localhost. So far I was unable to even push my migrations, I will try with the supabase CLI later today probably
KamKom
KamKom6mo ago
I’m self hosting supabase with coolify on a hetzner vps Today I managed to expose my postgres db by editing and exposing ports in the docker compose file I also use drizzle orm And have successfully generated migration and ran them only my supabase instance is self hosted, im building a nextjs app deployed on vercel and using drizzle orm to connect your my self hosted supabase I’ll need to try things out but so far its ok I didnt try auth yet but it should work
Want results from more Discord servers?
Add your server