3

Whenever i launch my app, part of my task is to first run a migration. however, I get the below error 95% of the time.

Command failed: /bin/sh -c node_modules/.bin/sequelize db:migrate
Unable to connect to database: SequelizeConnectionRefusedError: connect ECONNREFUSED

Details:
 killed: false
 code: 1
 signal: null
 cmd: /bin/sh -c node_modules/.bin/sequelize db:migrate
 stdout:
Sequelize [Node: 0.12.7, CLI: 2.1.0, ORM: 3.14.0]

Note: I can still query and connect to the database after the failure, also when i check the TCP lsof -i tcp:5432 its only one instance of postgres that runs.

I would appreciate any assistance in solving this issue.

1 Answers1

0

I had similar issue , but in my case it turn out I didn't start my posgres. Make sure your posgress is started and open otherwise Sequelize would fail. I just solve mine. Also mind your username and password . my connection is simple below.

var db ='postgres://user:@localhost:5432/my_db_naame'
var sequelize = new Sequelize(db);

where user is your database user . my_db_naame is your db name. See the doc here . I suggest you install posgres client terminal. Like the one here http://postgresapp.com/documentation/gui-tools.html . Make sure you open it and the elephant sign is shown on top . Or better connect , try your username and password. run some queries and then try your sequelize again.

Nuru Salihu
  • 4,756
  • 17
  • 65
  • 116