R
Railwayβ€’7mo ago
spidertwin2

Postgres Connection Error

My app is unable to connect with railway's postgres service. Also, when I used DATABASE_URL dbgate error is - Error: Connection terminated unexpectedly at e.exports.<anonymous> (/Applications/DbGate.app/Contents/Resources/app.asar/packages/plugins/dbgate-plugin-postgres/dist/backend.js:17:175293) at Object.onceWrapper (node:events:509:28) at e.exports.emit (node:events:390:28) at Socket.<anonymous> (/Applications/DbGate.app/Contents/Resources/app.asar/packages/plugins/dbgate-plugin-postgres/dist/backend.js:9:141124) at Socket.emit (node:events:402:35) at endReadableNT (node:internal/streams/readable:1343:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) Please help πŸ™
No description
No description
28 Replies
Percy
Percyβ€’7mo ago
Project ID: 6df8fc82-10e0-4b56-ab0b-b2ce2d7e52b5
spidertwin2
spidertwin2β€’7mo ago
6df8fc82-10e0-4b56-ab0b-b2ce2d7e52b5
Brody
Brodyβ€’7mo ago
can you try restarting the database?
spidertwin2
spidertwin2β€’7mo ago
did restart, still same error in console and dbgate
No description
spidertwin2
spidertwin2β€’7mo ago
Also, I cannot find a railway link xxxx-xxx-production.up.railway.app to my deployed app even after I do railway up..is it because my db is unable to connect?
Brody
Brodyβ€’7mo ago
restart the database, not your app if you don't have a domain yet, go to the service settings and generate one
spidertwin2
spidertwin2β€’7mo ago
this is probably very basic - how should I restart my db?
Brody
Brodyβ€’7mo ago
depends on if you have a legacy database or a database service. does your database have a volume?
spidertwin2
spidertwin2β€’7mo ago
Yes, my db has a volume
Brody
Brodyβ€’7mo ago
then you restart it the same way you restart a deployment
spidertwin2
spidertwin2β€’7mo ago
As I did here?
Brody
Brodyβ€’7mo ago
yes but restart the database, not your app
spidertwin2
spidertwin2β€’7mo ago
This is probably too much handholding, but please can you send me screenshots of steps β€” sorry for trouble
Brody
Brodyβ€’7mo ago
open the database and click this highlighted button in the 3 dot menu
No description
spidertwin2
spidertwin2β€’7mo ago
Already did, same error
Brody
Brodyβ€’7mo ago
can you connect to the database locally with dbgate?
spidertwin2
spidertwin2β€’7mo ago
No, tried using DATABASE_URL but not working
Brody
Brodyβ€’7mo ago
did you try with dbgate?
spidertwin2
spidertwin2β€’7mo ago
Error: Connection terminated unexpectedly at e.exports.<anonymous> (/Applications/DbGate.app/Contents/Resources/app.asar/packages/plugins/dbgate-plugin-postgres/dist/backend.js:17:175293) at Object.onceWrapper (node:events:509:28) at e.exports.emit (node:events:390:28) at Socket.<anonymous> (/Applications/DbGate.app/Contents/Resources/app.asar/packages/plugins/dbgate-plugin-postgres/dist/backend.js:9:141124) at Socket.emit (node:events:402:35) at endReadableNT (node:internal/streams/readable:1343:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) Error JSON: {} Connection: { "server": "***", "engine": "postgres@dbgate-plugin-postgres", "useDatabaseUrl": "***", "sshMode": "userPassword", "sshKeyfile": "***", "databaseUrl": "***" } Platform: darwin This is the error on dbgate
Brody
Brodyβ€’7mo ago
do you see any errors in the database logs?
spidertwin2
spidertwin2β€’7mo ago
of railway?
Brody
Brodyβ€’7mo ago
yes
spidertwin2
spidertwin2β€’7mo ago
no errors, build and deploy logs look okay
Brody
Brodyβ€’7mo ago
can you try again on a vpn?
spidertwin2
spidertwin2β€’7mo ago
what does this mean?
Brody
Brodyβ€’7mo ago
try connecting to the database while you're connected to a vpn
spidertwin2
spidertwin2β€’7mo ago
ohk, will try so, I deleted the service and created a new one...seemed to work fine then, I was able to execute yarn prisma db push to update db. I was even able to connect with dbgate. But when I did railway up from my local environment, the same error surfaced - database connection failed, dbgate connection failed. ok, so I realized my app needs two services --- one postgres for db, another empty service to deploy my app. I was using db service for deployment as well which created trouble. Now with railway up I am deploying to the second service (not db). This way, I am able to deploy my app and also get a railway provided url. is this the right way to do things?
Brody
Brodyβ€’7mo ago
I wasn't aware you where doing railway up into the database service, of course that would completely nuke the database. yes, a database and another blank service for the app is the correct way to go, glad you could figure this out