question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sequelize db:migrate not working on Heroku

See original GitHub issue

Hi,

I did all the following steps for creating a PG db on Heroku, but when I try to do a migration it doesn’t work and I get this error:

heroku run sequelize db:migrate
Running sequelize db:migrate on murmuring-refuge-53970... up, run.1235

Sequelize [Node: 5.11.0, CLI: 2.4.0, ORM: 3.22.0]

Loaded configuration file "server/db/sequelize/sequelize_config.js".
Using environment "production".
Unable to connect to database: SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432

Any ideas?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
iamademarcommented, Aug 26, 2016

Figured it out. On server/db/postgres/sequelize_config.js:

You should remove username, password, database and host on the production hash.

From this hash:

module.exports = {
  development: {
    username: process.env.PGUSER || 'root',
    password: null,
    database: 'react_webpack_node_development',
    host: '127.0.0.1',
    dialect: 'postgres'
  },
  test: {
    username: process.env.PGUSER || 'root',
    password: null,
    database: 'react_webpack_node_test',
    host: '127.0.0.1',
    dialect: 'postgres'
  },
  production: {
    use_env_variable: 'POSTGRES_DB_URL',
    username: process.env.PGUSER || 'root',
    password: null,
    database: 'react_webpack_node_production',
    host: '127.0.0.1',
    dialect: 'postgres'
  }

It should look something like this:

module.exports = {
  development: {
    username: process.env.PGUSER || 'root',
    password: null,
    database: 'react_webpack_node_development',
    host: '127.0.0.1',
    dialect: 'postgres'
  },
  test: {
    username: process.env.PGUSER || 'root',
    password: null,
    database: 'react_webpack_node_test',
    host: '127.0.0.1',
    dialect: 'postgres'
  },
  production: {
    use_env_variable: 'POSTGRES_DB_URL',
    dialect: 'postgres'
  }

Make sure the POSTGRES_DB_URL is the correct Heroku ENV variable for your postgres db url on heroku.

Hopefully this answer saves you time. 😃

1reaction
kuiro5commented, Aug 6, 2016

Having same issue on fresh clone. @coderjonny did you end up finding a solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sequelize migrations in heroku - node.js - Stack Overflow
When you initialize sequelize locally by running: sequelize -i. a migration folder, config folder, and config.json inside the config folder are created.
Read more >
Sequelize Automatic Database Migration and Seeding on ...
To automatically run migrations and seeders before the heroku app built, create Procfile contains migrate and seed command. # Procfileweb: npx ...
Read more >
Heroku Sequelize NodeJS apps step by step - AVENTRA
Heroku Sequelize NodeJS apps step by step. Data base in heroku should be migrated seperately. git push heroku master will not run migration....
Read more >
[Solved]-heroku sequelize: command not found-sequelize.js
If you want to run db:migrate using sequelize-cli then do the following steps: add sequelize-cli as a dependency in your package.json; add migrate:...
Read more >
Sequelize-CLI, Node, Heroku Error - Reddit
This is probably not a problem with npm. ... heroku run sequelize db:migrate --env production --app locals-deploy. Error:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found