DB connection issue
njgeek
PROOP

2 months ago

2026-01-05T14:10:25.562870680Z [err] ┌─────────────────────────────────────────────────────────┐ 2026-01-05T14:10:25.562874726Z [err] │ Update available 5.22.0 -> 7.2.0 │ 2026-01-05T14:10:25.562880621Z [err] │ │ 2026-01-05T14:10:25.562884634Z [err] │ This is a major update - please follow the guide at │ 2026-01-05T14:10:25.562889364Z [err] │ https://pris.ly/d/major-version-upgrade │ 2026-01-05T14:10:25.562897549Z [err] │ │ 2026-01-05T14:10:26.665758513Z [err] 2026-01-05 14:10:16.169 UTC [12509] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:10:26.665767445Z [err] 2026-01-05 14:10:16.169 UTC [12511] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:10:26.665775967Z [err] 2026-01-05 14:10:16.169 UTC [12510] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:26.665784587Z [err] 2026-01-05 14:10:16.169 UTC [12508] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:26.665793574Z [err] 2026-01-05 14:10:16.169 UTC [12512] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:10:26.665802778Z [err] 2026-01-05 14:10:16.170 UTC [12494] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:26.665810638Z [err] 2026-01-05 14:10:16.171 UTC [12350] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:26.665818244Z [err] 2026-01-05 14:10:20.759 UTC [12513] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:26.665883184Z [err] 2026-01-05 14:10:21.104 UTC [12514] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:27.275434191Z [err] │ Run the following to update │ 2026-01-05T14:10:27.275492251Z [err] └─────────────────────────────────────────────────────────┘ 2026-01-05T14:10:27.275503580Z [err] │ npm i --save-dev prisma@latest │ 2026-01-05T14:10:27.275518751Z [err] │ npm i @prisma/client@latest │ 2026-01-05T14:10:30.835263857Z [err] 2026-01-05 14:10:29.642 UTC [12516] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:10:30.835278080Z [err] 2026-01-05 14:10:29.643 UTC [12515] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:30.835286154Z [err] 2026-01-05 14:10:29.642 UTC [12518] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:10:30.835293415Z [err] 2026-01-05 14:10:29.644 UTC [12517] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:30.835299784Z [err] 2026-01-05 14:10:29.644 UTC [12519] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:10:33.936060497Z [err] 2026-01-05 14:10:33.643 UTC [12520] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:35.195236481Z [err] 2026-01-05 14:10:33.977 UTC [12521] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:10:56.204384012Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 14 2026-01-05T14:11:16.267454869Z [err] 2026-01-05 14:11:14.365 UTC [12526] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:11:16.267459929Z [err] 2026-01-05 14:11:14.365 UTC [12525] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:11:16.267465466Z [err] 2026-01-05 14:11:14.365 UTC [12527] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:11:16.267475107Z [err] 2026-01-05 14:11:14.366 UTC [12524] LOG: could not accept SSL connection: EOF detected 2026-01-05T14:11:16.267481166Z [err] 2026-01-05 14:11:14.369 UTC [12522] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:11:19.033292318Z [err] 2026-01-05 14:11:18.483 UTC [12528] LOG: could not receive data from client: Connection reset by peer 2026-01-05T14:11:19.033299718Z [err] 2026-01-05 14:11:18.870 UTC [12529] LOG: could not receive data from client: Connection reset by peer

$10 Bounty

22 Replies

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open ray-chen 2 months ago


ilyassbreth
FREE

2 months ago

your postgres is getting hammered with too many connection attempts. add these params to your database_url:

?connection_limit=5&pool_timeout=30&connect_timeout=30

also make sure you're using a prisma client singleton ;not creating new instances everywhere:

js

const globalForPrisma = global as { prisma?: PrismaClient }
export const prisma = globalForPrisma.prisma || new PrismaClient()
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

if that doesn't fix it completely, deploy pgbouncer (railway has a postgres + pgbouncer template). that'll properly pool connections at the database level


ilyassbreth
FREE

2 months ago

the issue is prisma's default pool size is way too high for railway's setup and you're overwhelming postgres which is why you see all those ssl/connection reset errors plus hitting railway's 500 logs/sec rate limit


ilyassbreth
FREE

2 months ago

hope this help you


njgeek
PROOP

2 months ago

Hi thanks for your help. Can you check if its fixed now or what else do I need to do?


njgeek

Hi thanks for your help. Can you check if its fixed now or what else do I need to do?

ilyassbreth
FREE

2 months ago

look at your railway logs , are you still seeing those "could not accept SSL connection" and "connection reset by peer" errors?

if the errors stopped , you're good


njgeek
PROOP

2 months ago

still happening. Can you help me with a fix to this issue?
2026-01-05T15:22:02.596278276Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 369 2026-01-05T15:22:39.169787176Z [err] 2026-01-05 15:22:34.544 UTC [12774] LOG: could not accept SSL connection: EOF detected 2026-01-05T15:22:39.169792821Z [err] 2026-01-05 15:22:34.545 UTC [12773] LOG: could not accept SSL connection: EOF detected 2026-01-05T15:22:39.169798392Z [err] 2026-01-05 15:22:34.545 UTC [12772] LOG: could not accept SSL connection: EOF detected 2026-01-05T15:22:39.169804535Z [err] 2026-01-05 15:22:34.545 UTC [12771] LOG: could not accept SSL connection: EOF detected 2026-01-05T15:22:39.169810778Z [err] 2026-01-05 15:22:34.545 UTC [12767] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169816607Z [err] 2026-01-05 15:22:34.545 UTC [12769] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169823396Z [err] 2026-01-05 15:22:34.545 UTC [12768] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169829399Z [err] 2026-01-05 15:22:34.545 UTC [12765] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169834922Z [err] 2026-01-05 15:22:34.545 UTC [12764] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169842669Z [err] 2026-01-05 15:22:34.545 UTC [12762] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169848288Z [err] 2026-01-05 15:22:34.545 UTC [12763] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.169852364Z [err] 2026-01-05 15:22:34.545 UTC [12770] LOG: could not accept SSL connection: EOF detected 2026-01-05T15:22:39.169857005Z [err] 2026-01-05 15:22:34.545 UTC [12766] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.172434425Z [err] 2026-01-05 15:22:34.545 UTC [12755] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.172446104Z [err] 2026-01-05 15:22:34.545 UTC [12760] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.176920116Z [err] 2026-01-05 15:22:34.545 UTC [12751] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:22:39.176929000Z [err] 2026-01-05 15:22:34.545 UTC [12754] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:23:12.595009482Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 31


ilyassbreth
FREE

2 months ago

you need pgbouncer immediately, in your railway project, right-click the canvas → "create" → "template" then search for "pgbouncer" and deploy the template (it'll connect to your existing postgres automatically if it's named "Postgres") ; once deployed, update your app's DATABASE_URL to use pgbouncer change port from 5432 to 6432 and keep everything else the same

so your url becomes:

postgresql://user:pass@pgbouncer.railway.internal:6432/db?connection_limit=5

pgbouncer will pool connections properly and stop the flood. your logs should clear up within minutes after deploying.

also double-check you're using a prisma singleton like this:

typescript

const globalForPrisma = global as { prisma?: PrismaClient }
export const prisma = globalForPrisma.prisma ?? new PrismaClient()
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

the issue is you're likely in a serverless/edge setup where each function creates its own connection pool and you're hitting 500+ connections/sec


njgeek
PROOP

2 months ago

done but now I'm getting a lot of errors like the following
2026-01-05T15:45:45.620779951Z [err] 2026-01-05 15:45:44.999 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T15:45:49.076356538Z [err] 2026-01-05 15:45:41.974 UTC [134] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:45:49.076363114Z [err] 2026-01-05 15:45:41.974 UTC [133] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:45:49.080401032Z [err] 2026-01-05 15:45:41.974 UTC [135] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:45:49.080413734Z [err] 2026-01-05 15:45:41.974 UTC [132] LOG: could not receive data from client: Connection reset by peer 2026-01-05T15:46:15.700961904Z [err] 2026-01-05 15:46:10.216 UTC [1] LOG C-0x55cf3fc30200: railway/postgres@10.155.235.90:36512 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T15:46:15.700974272Z [err] 2026-01-05 15:46:10.216 UTC [1] LOG C-0x55cf3fc2ff40: railway/postgres@10.155.235.90:36504 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T15:46:15.700982556Z [err] 2026-01-05 15:46:11.221 UTC [1] LOG S-0x55cf3fc38a00: railway/postgres@10.143.245.145:5432 new connection to server (from 10.228.216.78:46962) 2026-01-05T15:46:15.700990901Z [err] 2026-01-05 15:46:12.231 UTC [1] LOG S-0x55cf3fc38cc0: railway/postgres@10.143.245.145:5432 new connection to server (from 10.228.216.78:46964) 2026-01-05T15:46:15.700995520Z [err] 2026-01-05 15:46:13.245 UTC [1] LOG S-0x55cf3fc38f80: railway/postgres@10.143.245.145:5432 new connection to server (from 10.228.216.78:46972) 2026-01-05T15:46:15.701000824Z [err] 2026-01-05 15:46:14.262 UTC [1] LOG S-0x55cf3fc39240: railway/postgres@10.143.245.145:5432 new connection to server (from 10.228.216.78:46434) 2026-01-05T15:46:15.701037825Z [err] 2026-01-05 15:46:07.479 UTC [1] LOG C-0x55cf3fc2fc80: railway/postgres@10.155.235.90:34016 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T15:46:15.701042644Z [err] 2026-01-05 15:46:08.645 UTC [1] LOG S-0x55cf3fc38740: railway/postgres@10.143.245.145:5432 new connection to server (from 10.228.216.78:46950) 2026-01-05T15:46:15.701047656Z [err] 2026-01-05 15:46:10.216 UTC [1] LOG C-0x55cf3fc30780: railway/postgres@10.155.235.90:36522 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T15:46:15.701055365Z [err] 2026-01-05 15:46:10.216 UTC [1] LOG C-0x55cf3fc304c0: railway/postgres@10.155.235.90:36516 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T15:46:45.440587396Z [err] 2026-01-05 15:46:45.000 UTC [1] LOG stats: 2 xacts/s, 2 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 1558 B/s, out 7833 B/s, xact 336206 us, query 336206 us, wait 2259377 us 2026-01-05T15:47:45.475073758Z [err] 2026-01-05 15:47:44.996 UTC [1] LOG stats: 2 xacts/s, 2 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 1757 B/s, out 13112 B/s, xact 287762 us, query 287762 us, wait 0 us 2026-01-05T15:48:45.481448263Z [err] 2026-01-05 15:48:44.997 UTC [1] LOG stats: 1 xacts/s, 1 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 1331 B/s, out 8805 B/s, xact 306604 us, query 306604 us, wait 0 us 2026-01-05T15:48:52.476375285Z [err] [Nest] 1 - 01/05/2026, 3:48:52 PM  ERROR [PrismaService] Prisma Error: 2026-01-05T15:48:52.476381419Z [err] Invalid prisma.expenseReceipt.findMany() invocation: 2026-01-05T15:48:52.476387114Z [err] 2026-01-05T15:48:52.476394835Z [err] { 2026-01-05T15:48:52.476400819Z [err] where: { 2026-01-05T15:48:52.476408175Z [err] tenantId: "01KA3XYXCB6XZ7DQ9FJAG93DJT", 2026-01-05T15:48:52.476414017Z [err] ExpenseReceiptSample: { 2026-01-05T15:48:52.476420169Z [err] some: { 2026-01-05T15:48:52.476600548Z [err] sampleId: "01KE7D4Q3S8E4HZYQY61Q8T9BB" 2026-01-05T15:48:52.476609090Z [err] } 2026-01-05T15:48:52.476614822Z [err] } 2026-01-05T15:48:52.476620805Z [err] }, 2026-01-05T15:48:52.476627080Z [err] orderBy: { 2026-01-05T15:48:52.476674773Z [err] purchaseDate: "desc" 2026-01-05T15:48:52.476681971Z [err] }, 2026-01-05T15:48:52.476686622Z [err] include: { 2026-01-05T15:48:52.476690908Z [err] BankAccount: { 2026-01-05T15:48:52.476695659Z [err] include: { 2026-01-05T15:48:52.476700063Z [err] FinancialAccount: true 2026-01-05T15:48:52.476705660Z [err] } 2026-01-05T15:48:52.476711608Z [err] }, 2026-01-05T15:48:52.476717172Z [err] UploadedBy: true, 2026-01-05T15:48:52.476739408Z [err] ~~~~~~~~~~ 2026-01-05T15:48:52.476745928Z [err] BankTransaction: true, 2026-01-05T15:48:52.476752976Z [err] TravelRequest: { 2026-01-05T15:48:52.476759058Z [err] select: { 2026-01-05T15:48:52.476769298Z [err] id: true, 2026-01-05T15:48:52.


ilyassbreth
FREE

2 months ago

yes, the issue is you upgraded to prisma 7 but didn't finish the migration. prisma 7 needs a driver adapter or it breaks

run this:

npm i @prisma/adapter-pg pg
npx prisma generate

then update your prisma client setup:

js

import { Pool } from 'pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '@prisma/client'

const pool = new Pool({ connectionString: process.env.DATABASE_URL, max: 5 })
const adapter = new PrismaPg(pool)

const globalForPrisma = global as { prisma?: PrismaClient }
export const prisma = globalForPrisma.prisma ?? new PrismaClient({ adapter })
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

then redeploy. your pgbouncer is fine but the broken prisma client was causing failed queries → retries → connection spam


ilyassbreth
FREE

2 months ago

the connection flood is happening because your Prisma Client is broken after the 5.22 → 7.2 upgrade so queries fail, app retries, connections spam


ilyassbreth
FREE

2 months ago

let me know the result


njgeek
PROOP

2 months ago

I'm not sure why it cant reach the db. I keep getting Can't reach database server at pgbouncer.railway.internal:6432


njgeek

I'm not sure why it cant reach the db. I keep getting Can't reach database server at pgbouncer.railway.internal:6432

ilyassbreth
FREE

2 months ago

hostname format is correct BUT:

  1. check your actual pgbouncer service name in railway dashboard (could be "PGBouncer" or something else , it's case sensitive)

  2. in your app's DATABASE_URL variable, use this format:

postgresql://postgres:password@${{PGBouncer.RAILWAY_PRIVATE_DOMAIN}}:6432/railway?connection_limit=5

replace "PGBouncer" with the EXACT service name from your dashboard

  1. make sure pgbouncer is actually deployed and running (check its logs)

  2. u MUST set a PORT service variable on pgbouncer itself to 6432 (not just in the connection string) , this is required for railway's private networking to work

the reference variable syntax pulls the private domain automatically, you just need the right service name


ilyassbreth
FREE

2 months ago

postgresql://postgres:password@${{PGBouncer.RAILWAY_PRIVATE_DOMAIN}}:6432/railway?connection_limit=5

replace "PGBouncer" with your actual pgbouncer service name from railway dashboard


ilyassbreth
FREE

2 months ago

?


njgeek
PROOP

2 months ago

still giving me errors 2026-01-05T18:12:50.589003316Z [err] 2026-01-05 18:12:44.995 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T18:13:50.194054603Z [err] 2026-01-05 18:13:45.000 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T18:14:50.206428180Z [err] 2026-01-05 18:14:44.996 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T18:15:14.049698442Z [err] Loaded Prisma config from prisma.config.ts. 2026-01-05T18:15:14.049706455Z [err] 2026-01-05T18:15:14.295511344Z [err] Prisma schema loaded from prisma/schema.prisma. 2026-01-05T18:15:14.836954318Z [err] npm notice 2026-01-05T18:15:14.836971293Z [err] npm notice New major version of npm available! 10.8.2 -> 11.7.0 2026-01-05T18:15:14.836979785Z [err] npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0 2026-01-05T18:15:14.836987176Z [err] npm notice To update run: npm install -g npm@11.7.0 2026-01-05T18:15:14.836995124Z [err] npm notice 2026-01-05T18:15:25.884982334Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 541 2026-01-05T18:15:30.208559922Z [err] 2026-01-05 18:15:25.670 UTC [1] LOG C-0x55cf3fc30a40: railway/postgres@[fd12:a3d9:f7cc:1:8000:3d:6dac:69dc]:43644 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T18:15:30.208567905Z [err] 2026-01-05 18:15:27.029 UTC [1] LOG S-0x55cf3fc39240: railway/postgres@10.169.254.251:5432 new connection to server (from 10.228.216.78:34084) 2026-01-05T18:15:50.206040061Z [err] 2026-01-05 18:15:44.995 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 2 B/s, xact 946310 us, query 946310 us, wait 1409143 us 2026-01-05T18:16:13.491536616Z [err] Loaded Prisma config from prisma.config.ts. 2026-01-05T18:16:13.491542748Z [err] 2026-01-05T18:16:13.643617572Z [err] Prisma schema loaded from prisma/schema.prisma. 2026-01-05T18:16:18.736255089Z [err] Error: P1001: Can't reach database server at postgres.railway.internal:5432 2026-01-05T18:16:18.736262514Z [err] 2026-01-05T18:16:18.736268181Z [err] Please make sure your database server is running at postgres.railway.internal:5432. 2026-01-05T18:16:18.759143404Z [err] npm notice 2026-01-05T18:16:18.759152519Z [err] npm notice New major version of npm available! 10.8.2 -> 11.7.0 2026-01-05T18:16:18.759159949Z [err] npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0 2026-01-05T18:16:18.759170843Z [err] npm notice To update run: npm install -g npm@11.7.0 2026-01-05T18:16:18.759177596Z [err] npm notice 2026-01-05T18:16:29.834342966Z [err] 2026-01-05 18:16:24.608 UTC [1] LOG C-0x55cf3fc30200: railway/postgres@[fd12:a3d9:f7cc:1:8000:30:2f0f:4129]:44958 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T18:16:29.834351215Z [err] 2026-01-05 18:16:25.727 UTC [1] LOG S-0x55cf3fc38740: railway/postgres@10.169.254.251:5432 new connection to server (from 10.228.216.78:57986) 2026-01-05T18:16:30.519801657Z [err] 2026-01-05 18:16:30.515 UTC [1] LOG C-0x55cf3fc30a40: railway/postgres@[fd12:a3d9:f7cc:1:8000:3d:6dac:69dc]:43644 closing because: client unexpected eof (age=64s) 2026-01-05T18:16:37.344592468Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 477 2026-01-05T18:16:50.571572189Z [err] 2026-01-05 18:16:44.996 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 1 B/s, out 5 B/s, xact 475946 us, query 475946 us, wait 1169961 us 2026-01-05T18:17:01.898252985Z [err] [reset-password] Unexpected error: Error [PrismaClientInitializationError]: 2026-01-05T18:17:01.898414410Z [err] 2026-01-05T18:17:01.898423544Z [err] 2026-01-05T18:17:01.898430911Z [err] at async R (.next/server/chunks/[root-of-the-server]__0b80e278._.js:1:4162) 2026-01-05T18:17:01.898443515Z [err] errorCode: undefined 2026-01-05T18:17:01.898450313Z [err] Invalid prisma.user.findUnique() invocation: 2026-01-05T18:17:01.898456990Z [err] } 2026-01-05T18:17:01.898457954Z [err] Please make sure your database server is running at pgbouncer.railway.internal:6432. 2026-01-05T18:17:01.898458791Z [err] Can't reach database server at pgbouncer.railway.internal:6432 2026-01-05T18:17:01.898460469Z [err] at async d (.next/server/chunks/[root-of-the-server]__0b80e278._.js:66:3546) { 2026-01-05T18:17:01.898469219Z [err] at async (.next/server/chunks/[root-of-the-server]__3818dba8._.js:1:3808) 2026-01-05T18:17:01.898470969Z [err] 2026-01-05T18:17:01.898473991Z [err] clientVersion: '5.22.0',


njgeek
PROOP

2 months ago

i changed the pgbouncer to pgbouncer all lower case.


njgeek
PROOP

2 months ago

I got it working now but the pgbouncer is slowing down the website so much.


ilyassbreth
FREE

2 months ago

the slowness is because railway's pgbouncer defaults to session mode but prisma needs transaction mode

add these environment variables to your pgbouncer service:

PGBOUNCER_POOL_MODE=transaction
PGBOUNCER_DEFAULT_POOL_SIZE=20
PGBOUNCER_MAX_CLIENT_CONN=1000

then update your DATABASE_URL to include the pgbouncer flag:

postgresql://user:pass@pgbouncer.railway.internal:6432/db?pgbouncer=true

the ?pgbouncer=true flag tells prisma to disable prepared statements which dont work with transaction mode

redeploy both services. transaction mode releases connections after each transaction instead of holding them for the entire session so it's way faster


ilyassbreth
FREE

2 months ago

hope this help you :)


njgeek
PROOP

2 months ago

dont but still very slow. any other solutions? thanks a lot for your help


njgeek

still giving me errors 2026-01-05T18:12:50.589003316Z [err] 2026-01-05 18:12:44.995 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T18:13:50.194054603Z [err] 2026-01-05 18:13:45.000 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T18:14:50.206428180Z [err] 2026-01-05 18:14:44.996 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 0 B/s, xact 0 us, query 0 us, wait 0 us 2026-01-05T18:15:14.049698442Z [err] Loaded Prisma config from prisma.config.ts. 2026-01-05T18:15:14.049706455Z [err] 2026-01-05T18:15:14.295511344Z [err] Prisma schema loaded from prisma/schema.prisma. 2026-01-05T18:15:14.836954318Z [err] npm notice 2026-01-05T18:15:14.836971293Z [err] npm notice New major version of npm available! 10.8.2 -> 11.7.0 2026-01-05T18:15:14.836979785Z [err] npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0 2026-01-05T18:15:14.836987176Z [err] npm notice To update run: npm install -g npm@11.7.0 2026-01-05T18:15:14.836995124Z [err] npm notice 2026-01-05T18:15:25.884982334Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 541 2026-01-05T18:15:30.208559922Z [err] 2026-01-05 18:15:25.670 UTC [1] LOG C-0x55cf3fc30a40: railway/postgres@[fd12:a3d9:f7cc:1:8000:3d:6dac:69dc]:43644 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T18:15:30.208567905Z [err] 2026-01-05 18:15:27.029 UTC [1] LOG S-0x55cf3fc39240: railway/postgres@10.169.254.251:5432 new connection to server (from 10.228.216.78:34084) 2026-01-05T18:15:50.206040061Z [err] 2026-01-05 18:15:44.995 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 0 B/s, out 2 B/s, xact 946310 us, query 946310 us, wait 1409143 us 2026-01-05T18:16:13.491536616Z [err] Loaded Prisma config from prisma.config.ts. 2026-01-05T18:16:13.491542748Z [err] 2026-01-05T18:16:13.643617572Z [err] Prisma schema loaded from prisma/schema.prisma. 2026-01-05T18:16:18.736255089Z [err] Error: P1001: Can't reach database server at postgres.railway.internal:5432 2026-01-05T18:16:18.736262514Z [err] 2026-01-05T18:16:18.736268181Z [err] Please make sure your database server is running at postgres.railway.internal:5432. 2026-01-05T18:16:18.759143404Z [err] npm notice 2026-01-05T18:16:18.759152519Z [err] npm notice New major version of npm available! 10.8.2 -> 11.7.0 2026-01-05T18:16:18.759159949Z [err] npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0 2026-01-05T18:16:18.759170843Z [err] npm notice To update run: npm install -g npm@11.7.0 2026-01-05T18:16:18.759177596Z [err] npm notice 2026-01-05T18:16:29.834342966Z [err] 2026-01-05 18:16:24.608 UTC [1] LOG C-0x55cf3fc30200: railway/postgres@[fd12:a3d9:f7cc:1:8000:30:2f0f:4129]:44958 login attempt: db=railway user=postgres tls=no replication=no 2026-01-05T18:16:29.834351215Z [err] 2026-01-05 18:16:25.727 UTC [1] LOG S-0x55cf3fc38740: railway/postgres@10.169.254.251:5432 new connection to server (from 10.228.216.78:57986) 2026-01-05T18:16:30.519801657Z [err] 2026-01-05 18:16:30.515 UTC [1] LOG C-0x55cf3fc30a40: railway/postgres@[fd12:a3d9:f7cc:1:8000:3d:6dac:69dc]:43644 closing because: client unexpected eof (age=64s) 2026-01-05T18:16:37.344592468Z [err] Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate. Messages dropped: 477 2026-01-05T18:16:50.571572189Z [err] 2026-01-05 18:16:44.996 UTC [1] LOG stats: 0 xacts/s, 0 queries/s, 0 client parses/s, 0 server parses/s, 0 binds/s, in 1 B/s, out 5 B/s, xact 475946 us, query 475946 us, wait 1169961 us 2026-01-05T18:17:01.898252985Z [err] [reset-password] Unexpected error: Error [PrismaClientInitializationError]: 2026-01-05T18:17:01.898414410Z [err] 2026-01-05T18:17:01.898423544Z [err] 2026-01-05T18:17:01.898430911Z [err] at async R (.next/server/chunks/[root-of-the-server]__0b80e278._.js:1:4162) 2026-01-05T18:17:01.898443515Z [err] errorCode: undefined 2026-01-05T18:17:01.898450313Z [err] Invalid prisma.user.findUnique() invocation: 2026-01-05T18:17:01.898456990Z [err] } 2026-01-05T18:17:01.898457954Z [err] Please make sure your database server is running at pgbouncer.railway.internal:6432. 2026-01-05T18:17:01.898458791Z [err] Can't reach database server at pgbouncer.railway.internal:6432 2026-01-05T18:17:01.898460469Z [err] at async d (.next/server/chunks/[root-of-the-server]__0b80e278._.js:66:3546) { 2026-01-05T18:17:01.898469219Z [err] at async (.next/server/chunks/[root-of-the-server]__3818dba8._.js:1:3808) 2026-01-05T18:17:01.898470969Z [err] 2026-01-05T18:17:01.898473991Z [err] clientVersion: '5.22.0',

ilyassbreth
FREE

2 months ago

the real issue is you're still on prisma 5.22.0 (look in your error logs). you installed the adapter but never actually upgraded prisma itself

simplest fix: skip pgbouncer entirely and use direct connection with proper pooling

run:

npm install prisma@latest @prisma/client@latest
npx prisma generate

then remove all the adapter stuff and use this simple setup:

js

import { PrismaClient } from '@prisma/client'

const globalForPrisma = global as { prisma?: PrismaClient }

export const prisma = globalForPrisma.prisma ?? new PrismaClient({
  log: ['error']
})

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

update your DATABASE_URL back to direct postgres:

postgresql://user:pass@postgres.railway.internal:5432/railway?connection_limit=10&pool_timeout=20

so delete the pgbouncer service completely. for railway with next.js (not vercel serverless), direct connection is faster than pgbouncer. the extra network hop was slowing you down

redeploy, this should be way faster and solve all the connection issues


Loading...