Error: Connection terminated unexpectedly

Hello everyone I keep getting “Error: Connection terminated unexpectedly” when I hit the endpoint that makes a request to get the data from the PostgreSQL database.
I have hosted my Postgresql database on Render and I have created two tables.

The “/” route works fine but “/personaltodos” endpoint keeps loading and doesn’t give any json data.

You can check my express code here: todosapp-server/server.js at main · MubashirWaheed/todosapp-server · GitHub

I have setup the environment variables in the render
I also tried adding SSL flag bu doesn’t work (can check my commit history)

EDIT
I changed the port to 3000 and I am getting the following error in the logs

Error: connect ECONNREFUSED 127.0.0.1:5432
Jun 25 04:13:16 PM      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
Jun 25 04:13:16 PM    errno: -111,
Jun 25 04:13:16 PM    code: 'ECONNREFUSED',
Jun 25 04:13:16 PM    syscall: 'connect',
Jun 25 04:13:16 PM    address: '127.0.0.1',
Jun 25 04:13:16 PM    port: 5432

Can’t figure out what is the issue even after so much time

Hi there,

The issue here is the database connection URL environment variable you are using. Please set it to be the same value as the internal URL for your Render Postgres service.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.