a year 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
27 Replies
a year ago
does it connect at all?
a year 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
a year 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
a year ago
what is your neon hostname?
PGHOST="ep-autumn-salad-a2f3soq8-pooler.eu-central-1.aws.neon.tech"
PGUSER="neondb_owner"
PGPASSWORD="-"
PGDATABASE="neondb"
a year ago
looks fine
i saw on a stackoverflow post that adding these might help idleTimeoutMillis: 0,
connectionTimeoutMillis: 0,
a year 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!
a year ago
yeah sorry but this error wouldn't be railway platform related
a year 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
a year ago
run the database on railway
a year ago
no railway is not free
a year ago
a free trial
a year ago
you will have to at some point pay