Skip to content
Advertisement

Express.js app times out when attempting to query a PostgreSQL database

I’ve built an Express.js app, hosted by Heroku, with a non-embedded PostgreSQL database.

The app was running as intended until about a month ago, and for several months before that. However, when I logged in today, I ran into a serious problem.

Whenever I try to access any page which queries the database, it tries to load for a few seconds, and then gives me the standard Heroku “Application Error” page.

Accessing the Database through Javascript

This is what a portion of my code that queries the database looks like:

JavaScript

And this is what the logs look like when I run this code:

JavaScript

You’ll notice that the logs get to “Hello!” and “My!”, but not to “Lovely!”.

Accessing the Database through the Heroku CLI

It’s also worth noting that I can access the database through the Heroku CLI, and this is what my screen looks like when I do so:

JavaScript

The Bottom Line

Why is this happening, and what can I do about it?

Advertisement

Answer

I had same problem. adding

ssl: { rejectUnauthorized: false }

parameter to connection worked. I needed to upgrade pg package for it to work.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement