Error: connect ECONNREFUSED 127.0.0.1:5432 when connecting to a custom database

I’m trying to connect my Postgres database into my application but getting the following error.
I have made my database using Heroku and it looks like this

fce0d4230f4f2702f32fe4391c66840e651648f09b2fe789da04a88a60c3ac8f@eu2-3-233-55-123.compute-1.amazonaws.com:5432/dbv30ooq9lnsn9 (I have changed a few characters here for privacy)

my script files look like this


and this is my error on save and try

can someone please help me?

1 Like

@voletirajkumar have you managed to get your issue resolved?

strange I get the same kind of error but connecting to MongoDB: “[MongoNetworkError] failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)\n at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:126:14) {\n name: ‘MongoNetworkError’,\n errorLabels: [Array],\n [Symbol(mongoErrorContextSymbol)]: {}\n}]”

Please note that my database is in the cloud not localhost

1 Like