Getting Sequelize Errors when trying to deploy to Heroku
See original GitHub issueIm trying to deploy to heroku and and have done the standard heroku create and push commands and get the following log
$ heroku logs --tail
2015-07-17T05:52:12.914883+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T05:52:12.914885+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T05:52:12.914887+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T05:52:12.914888+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T05:52:12.914890+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T05:52:12.914891+00:00 app[web.1]: at net.js:459:14
2015-07-17T05:52:12.914893+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T05:52:13.764130+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T05:52:13.776036+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-17T08:40:55.185290+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-17T08:41:00.454693+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-07-17T08:41:02.287641+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-07-17T08:41:02.287670+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-07-17T08:41:03.722456+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED
2015-07-17T08:41:03.722465+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T08:41:03.722463+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T08:41:03.722467+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T08:41:03.722468+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T08:41:03.722470+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T08:41:03.722471+00:00 app[web.1]: at net.js:459:14
2015-07-17T08:41:03.722472+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T08:41:04.589456+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T08:41:04.606837+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-17T10:43:13.146023+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-17T10:43:17.738695+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-07-17T10:43:20.563395+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-07-17T10:43:20.563417+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-07-17T10:43:23.187284+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED
2015-07-17T10:43:23.187289+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T10:43:23.187291+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T10:43:23.187293+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T10:43:23.187294+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T10:43:23.187296+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T10:43:23.187299+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T10:43:23.187297+00:00 app[web.1]: at net.js:459:14
2015-07-17T10:43:24.101779+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T10:43:24.111661+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-17T14:55:48.345314+00:00 heroku[api]: Attach DATABASE resource by rahul@jobletics.com
2015-07-17T14:55:48.345314+00:00 heroku[api]: Release v4 created by rahul@jobletics.com
2015-07-17T14:55:48.505225+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-17T14:55:53.199095+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-07-17T14:55:55.143255+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-07-17T14:55:55.143320+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-07-17T14:55:56.136056+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED
2015-07-17T14:55:56.136061+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T14:55:56.136063+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T14:55:56.136065+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T14:55:56.136066+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T14:55:56.136068+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T14:55:56.136070+00:00 app[web.1]: at net.js:459:14
2015-07-17T14:55:56.136071+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T14:55:57.166962+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-17T14:55:57.168288+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-17T14:55:57.154470+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T14:56:01.094451+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-07-17T14:56:03.331534+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-07-17T14:56:03.331565+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-07-17T14:56:04.559552+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED
2015-07-17T14:56:04.559556+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T14:56:04.559561+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T14:56:04.559560+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T14:56:04.559563+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T14:56:04.559558+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T14:56:04.559566+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T14:56:04.559564+00:00 app[web.1]: at net.js:459:14
2015-07-17T14:56:05.608314+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-17T14:56:05.590100+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T15:15:20.324314+00:00 heroku[api]: Deploy 708589b by rahul@jobletics.com
2015-07-17T15:15:20.324314+00:00 heroku[api]: Release v5 created by rahul@jobletics.com
2015-07-17T15:15:20.395896+00:00 heroku[slug-compiler]: Slug compilation started
2015-07-17T15:15:20.395926+00:00 heroku[slug-compiler]: Slug compilation finished
2015-07-17T15:15:28.127060+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-07-17T15:15:30.647548+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-07-17T15:15:30.647460+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-07-17T15:15:32.297969+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED
2015-07-17T15:15:32.297978+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T15:15:32.297981+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T15:15:32.297984+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T15:15:32.297990+00:00 app[web.1]: at net.js:459:14
2015-07-17T15:15:32.297986+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T15:15:32.297992+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T15:15:32.297988+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T15:15:33.403335+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T15:15:43.603603+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-07-17T15:15:47.126463+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-07-17T15:15:47.126494+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2015-07-17T15:15:48.207736+00:00 app[web.1]: Unhandled rejection SequelizeConnectionRefusedError: connect ECONNREFUSED
2015-07-17T15:15:48.207744+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/pg/lib/client.js:171:5)
2015-07-17T15:15:48.207742+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:61:20
2015-07-17T15:15:48.207746+00:00 app[web.1]: at emit (events.js:107:17)
2015-07-17T15:15:48.207747+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:59:10)
2015-07-17T15:15:48.207749+00:00 app[web.1]: at Socket.emit (events.js:107:17)
2015-07-17T15:15:48.207750+00:00 app[web.1]: at net.js:459:14
2015-07-17T15:15:48.207752+00:00 app[web.1]: at process._tickCallback (node.js:355:11)
2015-07-17T15:15:49.050609+00:00 heroku[web.1]: Process exited with status 0
2015-07-17T15:15:21.765636+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-17T15:15:33.421267+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-17T15:15:33.422265+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-17T15:15:51.434243+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thawing-sierra-7836.herokuapp.com request_id=4fdf0c7d-5713-4eac-bfb7-1a20f5031fd3 fwd="50.177.220.150" dyno= connect= service= status=503 bytes=
2015-07-17T15:15:51.766589+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=thawing-sierra-7836.herokuapp.com request_id=e775bcaa-6e21-4bc3-9587-8a249a8e54eb fwd="50.177.220.150" dyno= connect= service= status=503 bytes=
2015-07-17T15:15:49.072186+00:00 heroku[web.1]: State changed from starting to crashed
I created Heroku postres addon and added the db details to my config.js file. My model/index.js file looks like this:
"use strict";
var fs = require("fs");
var path = require("path");
var Sequelize = require("sequelize");
var basename = path.basename(module.filename);
// Use env variable for our project.
var env = process.env.NODE_ENV || "development";
// Read config from `config/config.js`;
// `node_modules/.bin/sequelize -c config/config.js cmd`
var config = require(__dirname + '/../config/config.js')[env];
var sequelize = new Sequelize(config.database, config.username, config.password, config);
// Store the models.
var db = {};
fs
.readdirSync(__dirname)
.filter(function(file) {
return (file.indexOf(".") !== 0) && (file !== basename);
})
.forEach(function(file) {
var model = sequelize["import"](path.join(__dirname, file));
db[model.name] = model;
});
Object.keys(db).forEach(function(modelName) {
if ("associate" in db[modelName]) {
db[modelName].associate(db);
}
});
// Adds `sequelize` instance to db object.
db.sequelize = sequelize;
// Adds `Sequelize` class to db object.
db.Sequelize = Sequelize;
// Expose the db object.
module.exports = db;
My server.js looks like this:
// app dependencies
var morgan = require('morgan');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var express = require("express");
var isProduction = process.env.NODE_ENV === 'production';
var app = express();
//middleware
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json({
strict: false
}));
app.use(morgan(isProduction || 'dev'));
// static resources
app.use(express.static("./public"));
app.use(methodOverride());
// Use cookie middleware
app.use(cookieParser());
// Enable session management by express
app.use(session({
secret: 'changethis!',
resave: false,
saveUninitialized: false
}));
// Init the models
var db = require("./models");
db.sequelize
//You can set `force` to `true` in development mode.
.sync({
//force: true
})
//.sync()
.then(function() {
console.log('Express server listening on port 5000');
app.listen(5000);
});
var auth_handler = require('./lib/auth/passport.js')(app, db.User);
// resources routes
// app.use('/', require('./routes/web'));
//app.use('/api', auth_handler, require('./routes/api'));
app.use('/api', require('./routes/api'));
// default route for website
app.use( function(request, response) {
response.sendFile('./public/index.html', {root: __dirname});
});
Any idea whats going on?
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Express/sequelize app deployed to Heroku giving ...
connect(process.env.DATABASE_URL, function(err, client) {} ? I'm trying to figure out how to connect sequelize to heroku and am having issues.
Read more >Sequelize-CLI, Node, Heroku Error - Reddit
My app runs perfectly fine locally in development. I can run it serving static files from react build and I can run the...
Read more >How do I use Sequelize to connect to Heroku Postgres?
I'm seeing errors when attempting to use Sequelize in my node app. Resolution. This is the required configuration: const Sequelize = require('sequelize'); ...
Read more >Need advice with deployment error at Heroku-sequelize.js
[Solved]-Need advice with deployment error at Heroku-sequelize.js ... I'm not quite able to spot the issue, however maybe resetting all the dynos in...
Read more >Nodejs express postgres application failing on deployment
This error originated either by throwing inside of an async function ... I am trying get this working using PostgreSQL to move from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Simply because I know I’m going to run into this again:
For Heroku