"Request timeout" on Heroku - node.js

I am having a problem deploying my web app on Heroku. I already set the database on MongoDB Atlas. The database is working when I am running "node app.js" locally. After deploying my project on Heroku I got an Application error and when I run "heroku logs --tail" I got the error below ;
2020-03-07T19:53:58.266177+00:00 heroku[web.1]: Idling
2020-03-07T19:53:58.269259+00:00 heroku[web.1]: State changed from up to down
2020-03-07T19:53:59.799552+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-03-07T19:53:59.987938+00:00 heroku[web.1]: Process exited with status 143
2020-03-07T20:02:06.452667+00:00 heroku[web.1]: Unidling
2020-03-07T20:02:06.468513+00:00 heroku[web.1]: State changed from down to starting
2020-03-07T20:02:09.189010+00:00 heroku[web.1]: Starting process with command `node app.js`
2020-03-07T20:02:11.522634+00:00 app[web.1]: Server started on port 3000
2020-03-07T20:02:12.987457+00:00 heroku[web.1]: State changed from starting to up
2020-03-07T20:02:41.597213+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connection <monitor> to 35.172.242.193:27017 closed
2020-03-07T20:02:41.597235+00:00 app[web.1]: at new MongooseServerSelectionError (/app/node_modules/mongoose/lib/error/serverSelection.js:22:11)
2020-03-07T20:02:41.597236+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:808:32)
2020-03-07T20:02:41.597237+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:333:15)
2020-03-07T20:02:41.597237+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:14:10)
2020-03-07T20:02:41.597238+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:955:30)
2020-03-07T20:02:41.597238+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
2020-03-07T20:02:41.597239+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:811:32)
2020-03-07T20:02:41.597239+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:723:14)
2020-03-07T20:02:41.597239+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
2020-03-07T20:02:41.597240+00:00 app[web.1]: at internal/main/run_main_module.js:17:11
2020-03-07T20:02:41.597341+00:00 app[web.1]: (node:4) 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(). (rejection id: 1)
2020-03-07T20:02:41.597434+00:00 app[web.1]: (node:4) [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.
2020-03-07T20:02:43.524590+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=protected-coast-44428.herokuapp.com request_id=9a7b66e6-1280-4d0c-b13d-10548513bc70 fwd="159.146.14.191" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2020-03-07T20:03:17.579588+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=protected-coast-44428.herokuapp.com request_id=3d335054-de74-4abb-982c-135988919edb fwd="159.146.14.191" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
Please note that I don't have any favicon.ico in my project. I had it in my previous project and I deleted that project on Heroku because of this error, and I don't know why I am still getting favicon on my error.
I made sure that I wrote the right user name and password in app.js and I added my IP in the whitelist as well.
mongoose.connect("mongodb+srv://username:password*#cluster0-h6uqp.mongodb.net/todolistDB",
{ useNewUrlParser: true, useUnifiedTopology: true });

I solved the issue by changing networking access to 'ALLOW ACCESS FROM ANYWHERE' on MongoDB.
Here

Heroku on free plan, closes the dynos after 30 minutes of inactivity. More on this here.
Going by your logs, it looks like the mongo connection was closed after 30 minutes the app was started. Looks like you are affected by this.
The error though seems to be caused by no handling of mongo connection closing in the app.

Related

Heroku application stopped serving db2 connection

I have my app hosted on heroku for nearly 1 year, and in the past 24 hours, it stopped working. I get this in my logs:
2021-11-08T18:15:06.475815+00:00 app[web.1]: [Error: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "". Communication function detecting the error: "selectForConnectTimeout". Protocol specific error code(s): "115", "*", "*". SQLSTATE=08001
2021-11-08T18:15:06.475827+00:00 app[web.1]: ] {
2021-11-08T18:15:06.475828+00:00 app[web.1]: error: '[node-ibm_db] SQL_ERROR',
2021-11-08T18:15:06.475829+00:00 app[web.1]: sqlcode: -30081,
2021-11-08T18:15:06.475829+00:00 app[web.1]: state: '08001'
2021-11-08T18:15:06.475830+00:00 app[web.1]: }
2021-11-08T18:15:33.386490+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/login" host=www.mysite.ca request_id=3d627300-28d2-48af-a86e-60bdb950298a fwd="99.249.30.56" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
It seems to not like whatever is going on with db2. I can access my database no problem through my local machine, and see everything with in my db tables. I also have this directly from my heroku dashboard.
i am not able to figure out what the issue is. does anyone have any ideas?
Thanks to everyone for their answers. I did some more digging around, and turns out what solved it was reinstalling the db2 driver locally, and pushing it to heroku. Something must have changed that required an update to the db2 driver to connect with the heroku sevrer.

Password authentication failing for ghost blog on heroku server

I'm trying to setup Ghost(node.js blogging app) to run on a heroku server. I've followed this tutorial here but I'm getting an Application error when I load the app URL. Looking at the logs, I'm getting the following stack trace:
2016-12-16T10:00:08.185701+00:00 heroku[web.1]: Starting process with command `NODE_ENV=production node index.js`
2016-12-16T10:00:11.989635+00:00 app[web.1]:
2016-12-16T10:00:11.989655+00:00 app[web.1]: ERROR: password authentication failed for user "xxxxxxxxxxxxxx"
2016-12-16T10:00:11.989656+00:00 app[web.1]: error: password authentication failed for user "xxxxxxxxxxxxxx"
2016-12-16T10:00:11.989656+00:00 app[web.1]:
2016-12-16T10:00:11.989658+00:00 app[web.1]: at Connection.parseMessage (/app/node_modules/pg/lib/connection.js:361:17)
2016-12-16T10:00:11.989657+00:00 app[web.1]: at Connection.parseE (/app/node_modules/pg/lib/connection.js:534:11)
2016-12-16T10:00:11.989659+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/pg/lib/connection.js:105:22)
2016-12-16T10:00:11.989660+00:00 app[web.1]: at emitOne (events.js:96:13)
2016-12-16T10:00:11.989661+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2016-12-16T10:00:11.989662+00:00 app[web.1]: at TLSSocket.Readable.push (_stream_readable.js:134:10)
2016-12-16T10:00:11.989660+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2016-12-16T10:00:11.989663+00:00 app[web.1]: at TLSWrap.onread (net.js:548:20)
2016-12-16T10:00:11.989664+00:00 app[web.1]:
2016-12-16T10:00:12.059675+00:00 heroku[web.1]: Process exited with status 0
2016-12-16T10:00:12.098899+00:00 heroku[web.1]: State changed from starting to crashed
2016-12-16T10:00:11.574238+00:00 app[web.1]: WARNING: Ghost is attempting to use a direct method to send email.
2016-12-16T10:00:11.574254+00:00 app[web.1]: It is recommended that you explicitly configure an email service.
2016-12-16T10:00:11.575112+00:00 app[web.1]: Help and documentation can be found at http://support.ghost.org/mail.
2016-12-16T10:00:11.575114+00:00 app[web.1]:
2016-12-16T12:20:59.497399+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ai-blog.herokuapp.com request_id=a725a350-ade1-4f00-9b8a-125fac34eb23 fwd="82.46.0.56" dyno= connect= service= status=503 bytes=
2016-12-16T12:21:01.504908+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ai-blog.herokuapp.com request_id=cc0c4f9b-f3af-4867-942f-0c7f295f9b90 fwd="82.46.0.56" dyno= connect= service= status=503 bytes=
2016-12-16T12:21:03.381794+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ai-blog.herokuapp.com request_id=ee190254-0159-4ba0-aa74-6e58f661c966 fwd="82.46.0.56" dyno= connect= service= status=503 bytes=
It seems that the important part of the error here is that the password is failing: But I've double and tripled check the all of the heroku varibles are set correctly, i.e. no typos, no extra spaces added at the start end of the string.
Additionally, the app runs fine locally.
The issue seems relatively common, but I've tried most of the solutions from other posts and nothing seems to be resolving the issue.
Solutions that I've tried:
Checked all varibles for typos
Checked the correct database is promoted
Manually adding the user credendials to the remote database(For some reason I can still access the remote database through the command line)
Ran the following command heroku config:set PGSSLMODE=require
ensured that I'm using https in the url when connecting to the site through a browser
I've added the following to the db params in the production environment of my config.js ssl: true
I've also checked that I'm in production environment
Sugguestions that I haven't tried:
Someone suggested that node needs to be updated. But I can't see any way of updating whatever version of node it is that heroku uses.
Somone suggested that postgres needs to be updated. But I can't see any way of updating that on heroku servers either. However, I did update the version number in the package.json file from 4.1.1 to 4.5.5 and moved it from optionalDependencies to dependencies.
editing the pg_hba.conf - again, I imagine this file exists on heroku servers and I can't access it
Anyone got any ideas?
I encounter the same problem while trying to upgrade to Ghost version 0.11.3 and deploying to Heroku.
I was able to solve the problem by upgrading the PostgreSQL npm package.
In package.json:
{
"dependencies": {
"pg": "^4.5.5",
},
"optionalDependencies": {
"pg": "^4.5.5"
}
}
And you will also need to modify the npm-shrinkwrap.json file:
{
"dependencies": {
"pg": {
"version": "^4.5.5",
"from": "pg#4.5.5",
"resolved": "https://registry.npmjs.org/pg/-/pg-4.5.5.tgz",
"dependencies": {...}
}
}
}
After that, check that the PG npm package version was updated correctly by taking a look at Heroku's deploy log. It should say something like:
remote: -----> Build succeeded!
remote: ├── ...
remote: ├── pg#4.5.5
remote: ├── ...

MongoDB not connecting to Heroku? Application Error

I tested it out using npm modules: "node-dev" on the backend.js and "serve" on the root directory of the folder.
I have these 2 guides that tried to help me:
http://www.tilcode.com/deploying-a-mean-stack-app-to-heroku/
and another one from scotch.io "Use MongoDB with a Node.js Application on Heroku"
What I didn't do from the articles that shouldn't matter: in tilcode, it said use to github to generate an SSH key...instead I made one using my mac and a terminal command using some guide.
To summarize my steps:
Login to heroku, create the app
use git commands to add, commit all the files in my github into heroku and pushed them into heroku
I even put the mlab addon and filled out the URI.
It deployed "successfully" but when visiting the app, it says "application failed"
My suspicions:
I do have another working app that uses postgreSQL...but I put it on 'maintenance mode' since my free account only allows for one active dynamo.
Instead of uploading all my node modules, I learned I could have heroku install it like this:
heroku config:set NPM_CONFIG_PRODUCTION=false
I think it may be how I referenced the backend from my frontend javascript.
// var API = 'http://localhost:5000';
var API = 'http://limitless-falls-21423.herokuapp.com';
var app = angular.module('HAL-app', ['ngRoute', 'ngCookies']);
// Some other stuff that came from sandbox app.js
app.directive('whenScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
elm.bind('scroll', function() {
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
scope.$apply(attr.whenScrolled);
}
});
};
});
Lastly, when I ran heroku logs --tail I got these messages:
2016-09-05T01:35:27.417956+00:00 app[web.1]: npm ERR! Linux 3.13.0-93-generic
2016-09-05T01:35:27.418339+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-09-05T01:35:27.418593+00:00 app[web.1]: npm ERR! node v5.11.1
2016-09-05T01:35:27.418931+00:00 app[web.1]: npm ERR! npm v3.8.6
2016-09-05T01:35:27.419219+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-09-05T01:35:27.419386+00:00 app[web.1]: npm ERR! hallocam#1.0.0 start:
node backend.js
2016-09-05T01:35:37.178679+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=limitless-falls-21423.herokuapp.com request_id=4bc9639f-3f64-4c0b-9b0d-d99b967f1b36 fwd="73.54.129.252" dyno= connect= service= status=503 bytes=
******EDIT after Yashua's comment**
I now get a "cannot get" message when visiting the app. Was kinda hesitant about limiting my heroku variables to just the:
NODE_ENV=production
But I guess it makes since since if I keep my mongodb (mongo labs) credentials uploaded and hidden using .gitignore.
Anyway, I'm still thinking it's not "getting" my routes which I have setup my angularjs file like this:
// var API = 'http://localhost:5000'; ##this is the old way to connect my front end factory routes to the backend hosted on 5000
I have it like this right now
var API = 'http://obscure-brook-35938.herokuapp.com/';
I think it may have to look like this:
var API = process.env.PORT
The purpose of the API is to be used for my angular factories like this:
app.factory('backEnd', function($http) {
return {
getSignUp: function(data) {
return $http({
method: 'POST',
url: API + '/signup',
data: data
});
},
getLogin: function(data) {
return $http({
method: 'POST',
url: API + '/login',
data: data
});
},
New Heroku logs --tail
2016-09-05T15:42:52.796464+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brook-35938.herokuapp.com request_id=41fa32e2-42cc-426d-a0d0-ef6755329497 fwd="73.54.129.252" dyno=web.1 connect=1ms service=18ms status=404 bytes=243
2016-09-05T15:42:53.893156+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brook-35938.herokuapp.com request_id=dec235fd-6d54-42e6-b0cc-2f83920d500d fwd="73.54.129.252" dyno=web.1 connect=1ms service=8ms status=404 bytes=243
2016-09-05T15:42:54.602312+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brook-35938.herokuapp.com request_id=8ceb054b-78e9-49b8-bdee-286ca6efcb0d fwd="73.54.129.252" dyno=web.1 connect=1ms service=3ms status=404 bytes=243
Hard to tell offhand but here are some pointers:
I looked at your repo and your package.json is invalid in 2 places. Use a JSON validator.
Secondly your frontend app will not be an issue. You should be able to go to the server URL directly and not have it crashed.
Change your database password if you haven't already. I see that you deleted your mongo_creds.json file but the history is available on GitHub.
The only vars you should need on Heroku is NODE_CONFIG set to production.
I'm closing this thread because it's getting pretty lengthy and a separate problem has arose. As #yashua said, the best way to solve this mongodb/heroku problems is to take it one step at a time. Some tools I've learned from this experience:
If using NPMs to test, that's great as it builds confidence. But to truly test heroku, use its 'heroku local' or 'heroku local web' to test it out locally first (serve it up), then it'll help narrow down further issues when deploying/'git push heroku master'
Build a solid understanding of how .env files work (really, they're
just configuration files to store credential information). I've been
using .json files to store mine, then use .gitignore to stop them
from appearing publicly. Heroku has its own secret keepers in the
form of Procfile and .env
I'm up to a point now where I consolidated my backend/frontend into one root directory. But my frontend and backend use 2 different ports to work when it should only use one. Not sure the best way to approach that since when I do [supposedly] feed them all the same port as 'process.env.MONGOLAB_URI' I get an error that hints that I have it wrong.
2016-09-05T23:36:51.802697+00:00 app[web.1]: /app/node_modules/mongodb/lib/server.js:261
2016-09-05T23:36:51.802698+00:00 app[web.1]: process.nextTick(function() { throw err; })
2016-09-05T23:36:51.802698+00:00 app[web.1]: ^
2016-09-05T23:36:51.803862+00:00 app[web.1]: MongoError: failed to connect to server [#:27017] on first connect
2016-09-05T23:36:51.803864+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:313:35)
2016-09-05T23:36:51.803864+00:00 app[web.1]: at emitOne (events.js:96:13)
2016-09-05T23:36:51.803865+00:00 app[web.1]: at Pool.emit (events.js:188:7)
2016-09-05T23:36:51.803865+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:260:12)
2016-09-05T23:36:51.803866+00:00 app[web.1]: at Connection.g (events.js:286:16)
2016-09-05T23:36:51.803867+00:00 app[web.1]: at emitTwo (events.js:106:13)
2016-09-05T23:36:51.803867+00:00 app[web.1]: at Connection.emit (events.js:191:7)
2016-09-05T23:36:51.803868+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:162:49)
2016-09-05T23:36:51.803868+00:00 app[web.1]: at Socket.g (events.js:286:16)
2016-09-05T23:36:51.803869+00:00 app[web.1]: at emitOne (events.js:96:13)
2016-09-05T23:36:51.803870+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2016-09-05T23:36:51.803870+00:00 app[web.1]: at connectErrorNT (net.js:1016:8)
2016-09-05T23:36:51.803871+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:74:11)
2016-09-05T23:36:51.803871+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:98:9)
2016-09-05T23:36:51.881752+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-05T23:36:51.867426+00:00 heroku[web.1]: Process exited with status 1

Heroku deployment error

I've successfully pushed my app to heroku, but when I heroku open I get an Application error on my page.
Checking the logs I can see
2016-02-06T17:06:42.092148+00:00 heroku[slug-compiler]: Slug compilation started
2016-02-06T17:06:42.092157+00:00 heroku[slug-compiler]: Slug compilation failed:
failed to compile Node.js app
2016-02-06T17:07:00.738280+00:00 heroku[router]: at=info code=H81 desc="Blank ap
p" method=GET path="/" host=pacific-headland-94684.herokuapp.com request_id=9bcd
ba26-7eef-4323-baff-86e4f6cc7c11 fwd="109.175.110.196" dyno= connect= service= s
tatus=502 bytes=
And later on in the logs I also get
2016-02-09T16:20:30.835195+00:00 heroku[slug-compiler]: Slug compilation finished
2016-02-09T16:20:32.198289+00:00 heroku[web.1]: Starting process with command `n
ode server.js`
2016-02-09T16:20:34.904089+00:00 app[web.1]: throw err;
2016-02-09T16:20:34.904090+00:00 app[web.1]: ^
2016-02-09T16:20:34.904079+00:00 app[web.1]: module.js:338
2016-02-09T16:20:34.904092+00:00 app[web.1]: at Function.Module._load (modul
e.js:278:25)
2016-02-09T16:20:34.904091+00:00 app[web.1]: Error: Cannot find module '/app/ser
ver.js'
2016-02-09T16:20:34.904092+00:00 app[web.1]: at Function.Module._resolveFile
name (module.js:336:15)
2016-02-09T16:20:34.904093+00:00 app[web.1]: at Function.Module.runMain (mod
ule.js:501:10)
2016-02-09T16:20:34.904094+00:00 app[web.1]: at startup (node.js:129:16)
2016-02-09T16:20:34.904094+00:00 app[web.1]: at node.js:814:3
2016-02-09T16:20:35.976063+00:00 heroku[web.1]: Process exited with status 1
2016-02-09T16:20:35.977672+00:00 heroku[web.1]: State changed from starting to c
rashed
If anyone is interested for full logs, here's a link: https://www.dropbox.com/s/8l261wmg99yahzc/heroku_logs.txt?dl=0
All the similar problems I googled usually happen when pushing the app to heroku, but as I've said my push was successful.
The problem was that git repo was not in the apps folder(named node in my case) but in a folder up one level (named app, this folder didn't exist on local), so when I pushed it on heroku, procfile searched for server.js in folder named app instead of the root and couldn't find anything.
After checking the pathing on GitDesktop I saw the folder structure and reinitialized the repository in a right place, pushed the changes and fixed the problem.

Use Heroku addon mongolab with node.js

I am using node.js with mongo lab and I have followed the mongolab tutorial (https://devcenter.heroku.com/articles/mongolab#getting-your-connection-uri) to change my url of db like this in my code:
module.exports = new Db(settings.db, new Server('mongodb://heroku_app3178:e6dd5g3btvanua3gfbmk6#ds051740.mongolab.com', 51740, {}), {safe: true});
I tested with local run, and I indeed see node is trying to connect to this new URL.
But when I deploy to Heroku. Heroku always complain about this.
I tried different things for 3 hours got no clue.
This is my log, could you please help?
2014-11-20T06:35:55.290572+00:00 heroku[api]: Release v17 created by abcc#gmail.com
2014-11-20T06:35:57.385492+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-11-20T06:35:58.836675+00:00 heroku[web.1]: State changed from starting to up
2014-11-20T06:35:59.876883+00:00 app[web.1]: app.usr local
2014-11-20T06:36:00.396662+00:00 app[web.1]: at Socket.emit (events.js:95:17)a
2014-11-20T06:36:00.394396+00:00 app[web.1]:
2014-11-20T06:36:00.396664+00:00 app[web.1]: at net.js:440:14
2014-11-20T06:36:00.394894+00:00 app[web.1]: throw err;
2014-11-20T06:36:00.396665+00:00 app[web.1]: at process._tickCallback (node.js:419:13)
2014-11-20T06:36:00.396651+00:00 app[web.1]: Error: Error connecting to database: failed to connect to [127.0.0.1:27017] ====> why is this? so confused
2014-11-20T06:36:00.394918+00:00 app[web.1]: ^
2014-11-20T06:36:00.396654+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
2014-11-20T06:36:00.396656+00:00 app[web.1]: at emit (events.js:106:17)
2014-11-20T06:36:00.396659+00:00 app[web.1]: at emit (events.js:98:17)
2014-11-20T06:36:00.396658+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2014-11-20T06:36:00.396661+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
2014-11-20T06:36:00.394676+00:00 app[web.1]: /app/node_modules/connect-mongo/lib/connect-mongo.js:178
2014-11-20T06:36:00.415816+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=enigmatic-coast-5373.herokuapp.com request_id=165ef7e7-a68a-44b0-9706-f72fcd9a0ba4 fwd="54.83.129.179" dyno=web.1 connect=2ms service=540ms status=503 bytes=0
2014-11-20T06:36:01.075007+00:00 heroku[web.1]: State changed from crashed to starting
2014-11-20T06:36:01.074333+00:00 heroku[web.1]: State changed from up to crashed
2014-11-20T06:36:01.057123+00:00 heroku[web.1]: Process exited with status 8
2014-11-20T06:36:02.976453+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-11-20T06:36:04.328809+00:00 heroku[web.1]: State changed from starting to up
Your error message is showing that you're trying to connect to your local database on localhost (127.0.0.1).
What you should be doing in your code is using your Herkou environment variables, eg:
module.exports = new Db(settings.db, new Server(process.env.MONGOLAB_URL, {}), {safe: true});
You can connect to your remote mongodb specifying it in the code, and this will affect to the local and cloud implementation, or in heroku, you can use environment variables for cloud use. Go to your app-settings-reveal config vars, and add,
first field: MONGOLAB_URI
second field: mongodb://yourmongolabuser:yourmongolabpass#dsnumber.mongolab.com:number/yourapp
MongoLab shows you the uri, you only must change de User and Password.
Another thing can helps your node app not to crash is changing mode to production, again in env variables:
NODE_ENV=production

Resources