6 months ago
Hey! I've created an app using node.js and for the database using neon, but my app is crashing. I did what this tutorial told me https://neon.tech/docs/guides/railway and i get these errors on the deploy logs.
Database connection error: Error: Connection terminated unexpectedly
at /app/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
/app/node_modules/pg-pool/index.js:45
Error.captureStackTrace(err)
^
Error: Connection terminated unexpectedly
at /app/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getPgVersion (/app/app.js:21:20)
Also here is the app.js file https://github.com/Orion-Barjamaj/Inventory-Application/blob/main/app.js
0 Replies
6 months ago
does it connect at all?
6 months ago
check out the docs on that -
nevermind still the same it crashed here are the deploy logs Database connection error: Error: Connection terminated unexpectedly
at /app/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
/app/node_modules/pg-pool/index.js:45
Error.captureStackTrace(err)
^
Error: Connection terminated unexpectedly
at /app/node_modules/pg-pool/index.js:45:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getPgVersion (/app/app.js:21:20)
Node.js v18.20.2
i think the problem may be at how i am connecting with my neon database
6 months ago
you arent using a port
const port = process.env.PORT || 5432;
// Connect to database
const { Pool } = require('pg');
const { PGHOST, PGDATABASE, PGUSER, PGPASSWORD } = process.env;
const pool = new Pool({
host: PGHOST,
database: PGDATABASE,
username: PGUSER,
password: PGPASSWORD,
port: port,
});
its kinda weird since the project works fine on local. Also it's my first time doing a project with a database with different providers so yeah
6 months ago
what is your neon hostname?
PGHOST="ep-autumn-salad-a2f3soq8-pooler.eu-central-1.aws.neon.tech"
PGUSER="neondb_owner"
PGPASSWORD="-"
PGDATABASE="neondb"
6 months ago
looks fine
i saw on a stackoverflow post that adding these might help idleTimeoutMillis: 0,
connectionTimeoutMillis: 0,
6 months ago
i think you would want to get in contact with neon for this instead of railway tbh
Oh alright I'll contact them hope I fix this as soon as possible lol thanks!
6 months ago
yeah sorry but this error wouldn't be railway platform related
6 months ago
we do not block or close any outbound connections
by the way would you recommend me some other database service i could use in the future if you can
6 months ago
run the database on railway
6 months ago
no railway is not free
6 months ago
a free trial
6 months ago
you will have to at some point pay