Nodejs express postgres application failing on deployment

I have this application that works on my mac with postgres fine but when I deploy to render it fails with the following error

Dec 18 01:29:36 PM (Use node --trace-warnings ... to show where the warning was created)
Dec 18 01:29:36 PM (node:53) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line API | Node.js v19.3.0 Documentation). (rejection id: 1)
Dec 18 01:29:36 PM (node:53) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Git repo is here - GitHub - kaziislam/just-tech-news-pg

Any help/suggestion would be appreciated.

Hi there

Without seeing the actual error its hard to debug…but It looks like you’re trying to connect to your local postgres database:
just-tech-news-pg/connection.js at main · kaziislam/just-tech-news-pg (

And this probably throwing the exception (that you’re not catching or logging)

You need to point sequelize to a database it can connect to. For example a render managed postgres.

Hi there,

Thanks for reaching out.

I imagine there’s more to that error trace, and I agree with Bergur’s suggestion that it looks like localhost is the hardcoded host in your connection settings.

If you’re still having issues after checking/correcting that config, please could you share some specific details of the issue you are experiencing that may help us troubleshoot it with you, e.g. full logs/errors/output, service name/ID, reproduction steps, screenshots, etc. If you don’t want to share these details on the community forum, please feel free to raise a ticket from the “Contact Support” link at the bottom of the Dashboard.



Thanks both of you. I did create a variable to point to the postgresql database instance I created on render and connected using postgres:// internal and external (tried both ways, just to make sure it is not db connection causing issue). But I left as localhost is still there might be my problem.

If you create an environment variable called DATABASE_URL with the “Internal Database URL” from the Render Postgres instance, you should be able to connect with just:

const sequelize = new Sequelize(process.env.DATABASE_URL)

As covered in their docs:

Once you get the connection sorted, you can expand on what other configuration you want.


Changing just-tech-news-pg/connection.js at main · kaziislam/just-tech-news-pg · GitHub the deployment started working but it only created one table (User) and getting new error

HERE table_schema = 'public' AND table_name = 'post' Dec 20 10:15:15 PM Executing (default): CREATE TABLE IF NOT EXISTS "post" ("id" SERIAL , "title" VARCHAR(255) NOT NULL, "post_url" VARCHAR(255) NOT NULL, "user_id" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id")); Dec 20 10:15:15 PM (node:52) UnhandledPromiseRejectionWarning: Error

Which I think it is complaining about a catch here

I am not following why this is not working in Render. I have deployed this exact application on my mac and also in Heroku using MySQL and works fine. I am trying get this working using PostgreSQL to move from Heroku.

Any points/suggestion would be really appreciated.



There will always be differences between environments development mode/Local, production mode/Render, etc. And most likely database vendors. These differences need to be considered and configured as required for your own app in each environment. Every app is different, their purpose, style & implementation can vary wildly so we’re unable to provide general debugging help as you’re the one that will know your app best.

You probably need to find a way to show that error to see what’s actually happening, it looks like the that CREATE TABLE query is failing. At a guess, that SQL doesn’t quite read right to me. If Sequelize is generating that SQL, I would expect a User model (that it’s trying to create a foreign key to with REFERENCES) to be in a table called users not user. Maybe check your association declarations. Or if you want to skip the middleman (Sequelize), then run that query in a psql (wrapped in a transaction) to see how Postgres handles it.


Thank you Alan. That’s a good hint for me. I got it working :slight_smile: Appreciate all your help!

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