Fresh PostgreSQL Database Can't Connect
Anonymous
HOBBYOP

6 months ago

2025-09-13T14:38:28.010981928Z [err] 2025-09-13 14:38:27.175 UTC [76] LOG: checkpoint complete: wrote 47 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=4.421 s, sync=0.009 s, total=4.446 s; sync files=12, longest=0.005 s, average=0.001 s; distance=270 kB, estimate=270 kB; lsn=0/1959210, redo lsn=0/1959180

2025-09-13T14:39:48.421999508Z [err] 2025-09-13 14:39:38.084 UTC [117] LOG: invalid length of startup packet

2025-09-13T14:39:48.422005846Z [err] 2025-09-13 14:39:38.551 UTC [118] LOG: invalid length of startup packet

2025-09-13T14:39:48.422012622Z [err] 2025-09-13 14:39:39.273 UTC [120] LOG: invalid length of startup packet

2025-09-13T14:39:48.422018182Z [err] 2025-09-13 14:39:39.772 UTC [121] LOG: invalid length of startup packet

2025-09-13T14:39:48.422724353Z [err] 2025-09-13 14:39:40.262 UTC [122] LOG: invalid length of startup packet

Solved$10 Bounty

6 Replies

Railway
BOT

6 months ago


Your PostgreSQL "invalid length of startup packet" errors mean something (likely health checks or your app) is trying to connect using HTTP instead of the PostgreSQL protocol. Fix it by using the correct connection string format postgresql://postgres:yourpassword@your-db.railway.internal:5432/railway or Railway's DATABASE_URL environment variable, and disable any HTTP health checks on your PostgreSQL service since databases don't need them they're causing these false connection attempts that PostgreSQL rightfully rejects.


Anonymous
HOBBYOP

6 months ago

i am using prisma, using that i can't connect
```
PGPASSWORD=xxxx psql -h shinkansen.proxy.rlwy.net -U postgres -p xxxx -d railway
```
it can connect via psql

i don't think it's prisma issue since i can connect to a postgresql docker container locally


Anonymous
HOBBYOP

6 months ago

i wasn't dumb
the solution was adding connect timeout to the uri
for prisma
`?connect_timeout=10`

postgresql://postgres:xxxx@example.net:xxxx/railway?connect_timeout=10


Anonymous
HOBBYOP

6 months ago

if i accept my own solution will i get the bounty not like i need it

idc


6 months ago

You do not but, I will mark it all the same!


Status changed to Awaiting User Response Railway 6 months ago


Status changed to Solved jake 6 months ago


Loading...