0

I have an app that is using express and sequelize. I built the app a month ago and everything was working fine. The client wanted to wait to finish it because they ran out of money. They contacted me so I opened up the app and when I ran it I got a clean exit. I have since isolated the issue to the sequelize connection and specifically the postgreSQL connection as it booted right up when i switched the connection to a mysql database. I know the user/pass/host/port/dbname are correct and the postgre server is running. Anybody have any ideas why this is happening?

This is the sequelize connection/server start code:

require('./config').sync()
  .then(() => app.listen(process.env.PORT || 3000))
  .catch(e => console.error(e))

This is my db config file:

const Sequelize = require('sequelize')

module.exports = new Sequelize(process.env.DATABASE_URL || process.env.LOCAL_URL)

This is my local_url .env variable:

postgres://root:password@localhost:5432/aoo_db

I know this code works as it was working before and it works with a mysql database.

3
  • Can you post the error message? Commented May 24, 2020 at 8:04
  • No error just server is not starting. It's a clean exit:[nodemon] starting `node server.js` [nodemon] clean exit - waiting for changes before restart Commented May 24, 2020 at 8:09
  • Also, I forgot to mention the app is currently deployed on heroku and running fine.So I guess this is a local issue. Commented May 24, 2020 at 8:14

1 Answer 1

3

Ok so what I did was just reinstall the postgres npm packages. It's weird because I deleted and reinstalled my node_modules multiple times and it didn't work but once i deleted and reinstall pg individually it started working.

Sign up to request clarification or add additional context in comments.

2 Comments

that was it. More details: i had "sequelize": "^5.22.3" and "pg": "^7.11.0". after npm uninstall pg and npm install pg i got "pg": "^8.5.1". Now it's working. Thanks for saving hours of debugging.
i've been debugging this for a couple hours and finally stumbled across this. I had an app that was working fine for months (years maybe). ( upgraded node to 17 from 12. I was on pg 6.4.2 and upgraded to 8.7.1 and everything worked like a charm! :clap:

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.