database not connecting
ramsupport
PROOP

4 months ago

database is ot getting connected,,it stopped sudeenly..no changes were made to the code..so i deleted th service and created new..its still not connecting

$10 Bounty

6 Replies

Railway
BOT

4 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


4 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 brody 4 months ago


fra
HOBBYTop 10% Contributor

4 months ago

can you share some db logs? how are the metrics? how is the volume?


ramsupport
PROOP

4 months ago

not connecting to datase vis private url..its connecting via public only

Attachments


arpitjacob
PRO

3 months ago

Same here didn't touch our database now its not connecting?


anarchistmanifesto
TRIAL

3 months ago

hey @ramsupport @arpitjacob

sounds like a common glitch with private networking on railway

ive seen this pop up a few times

first try adding a short sleep before your db connect code

like 3 seconds to let the network spin up

heres a quick example in node

const sleep = ms => new Promise(r => setTimeout(r ms))

await sleep(3000)

// then your db connect

if your container is alpine based

go to service variables and add this

ENABLE_ALPINE_PRIVATE_NETWORKING=true

that fixes compat issues

test with private url after

if still stuck share those logs @fra mentioned

metrics and volume too

hope that gets you going


mujirin
PRO

3 months ago

Hi, my story might help you. I have similar problem in my Django app with Postgres database, I have solved the problem, here the summary:

The error:

App do not respond

502 Bad Gateway

The log:

DETAIL: The database was created using collation version 2.36, but the operating system provides version 2.41.

HINT: Rebuild all objects in this database that use the default collation and run ALTER DATABASE railway REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.

Operations to perform:

Apply all migrations: <all table listed here>

What I am done to fix:

1. Backup in the local

BACKUP

436 export PGHOST="pghost"

437 export PGPORT="pgport"

438 export PGUSER="pguser"

439 export PGPASSWORD="pgpassword"

440 export PGDATABASE="pgdatabase"

441 export PGSSLMODE="require"

442 pg_dump --no-owner --no-privileges --format=plain > backup.sql

after finish

443 ls

you will get

backup.sql

  1. TEST

444 createdb test_restore\npsql test_restore < backup.sql\npsql test_restore -c "\dt"\n

you will get error here

  1. ALTER and REINDEX

445 psql -d postgres -c "ALTER DATABASE template1 REFRESH COLLATION VERSION;"\n

446 psql -d postgres -c "ALTER DATABASE postgres REFRESH COLLATION VERSION;"\n

447 psql -d postgres -c "ALTER DATABASE railway REFRESH COLLATION VERSION;"\n

448 psql -d postgres -c "REINDEX DATABASE railway;"\n

449 psql -d railway -c "REINDEX DATABASE railway;"\n

450 psql -d postgres -c "ALTER DATABASE postgres REFRESH COLLATION VERSION;"\n

451 psql -d postgres -c "ALTER DATABASE railway REFRESH COLLATION VERSION;"\n

452 psql -d railway -c "REINDEX DATABASE railway;"\n

453 psql -d railway -c "SELECT current_database();"\n

454 psql -d railway -c "VACUUM (ANALYZE);"\n

455 psql -d railway -c "SELECT pg_database_size(current_database());"\n

Hope this help you.


Loading...