I need help deploying my app

orion-barjamaj
TRIAL

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

orion-barjamaj
TRIAL

6 months ago

953a689f-47cd-491d-88a5-0e347fc11d93


orion-barjamaj
TRIAL

6 months ago

I need help deploying my app


6 months ago

does it connect at all?


orion-barjamaj
TRIAL

6 months ago

nope


orion-barjamaj
TRIAL

6 months ago

now its asking for a start command


6 months ago

check out the docs on that -


orion-barjamaj
TRIAL

6 months ago

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


orion-barjamaj
TRIAL

6 months ago

i think the problem may be at how i am connecting with my neon database


6 months ago

you arent using a port


orion-barjamaj
TRIAL

6 months ago

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,
});

orion-barjamaj
TRIAL

6 months ago

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?


orion-barjamaj
TRIAL

6 months ago

PGHOST="ep-autumn-salad-a2f3soq8-pooler.eu-central-1.aws.neon.tech"
PGUSER="neondb_owner"
PGPASSWORD="-"
PGDATABASE="neondb"


6 months ago

looks fine


orion-barjamaj
TRIAL

6 months ago

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


orion-barjamaj
TRIAL

6 months ago

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


orion-barjamaj
TRIAL

6 months ago

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


orion-barjamaj
TRIAL

6 months ago

is it free?


6 months ago

no railway is not free


orion-barjamaj
TRIAL

6 months ago

Im pretty sure im using it for free


6 months ago

a free trial


6 months ago

you will have to at some point pay


orion-barjamaj
TRIAL

6 months ago

oh alr thanks