I want to deploy my app to heroku using mlab as a service. When I push to heroku and check my heroku logs, I get the error:
MongoError: Authentication failed.
I did some research and it seems to be because my MongoDB shell and server versions don't match. When I try to connect using the mongo shell by typing:
mongo ds129610.mlab.com:29610/heroku_tnswz69w -u <dbuser> -p <dbpassword>
I get:
MongoDB shell version v3.4.2
connecting to: mongodb://ds129610.mlab.com:29610/heroku_tnswz69w
MongoDB server version: 3.2.12
WARNING: shell and server versions do not match
2017-03-14T16:06:21.842-0700 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1459:20
#(auth):6:1
#(auth):1:2
exception: login failed
I've tried to upgrade my server version, but I have not been successful. How can I resolve this issue? Here are my heroku logs, just in case that this isn't the only issue:
2017-03-14T20:14:44.000000+00:00 app[api]: Build succeeded
2017-03-14T20:14:59.777446+00:00 app[api]: Release v9 created by user corey.archharr#gmail.com
2017-03-14T20:14:59.941332+00:00 heroku[web.1]: State changed from crashed
to starting
2017-03-14T20:15:02.970234+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-03-14T20:15:05.774946+00:00 app[web.1]:
2017-03-14T20:15:05.774962+00:00 app[web.1]: events.js:160
2017-03-14T20:15:05.774963+00:00 app[web.1]: throw er; // Unhandled 'error' event
2017-03-14T20:15:05.774964+00:00 app[web.1]: ^
2017-03-14T20:15:05.776680+00:00 app[web.1]: MongoError: Authentication failed.
2017-03-14T20:15:05.776682+00:00 app[web.1]: at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
2017-03-14T20:15:05.776683+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:483:72
2017-03-14T20:15:05.776684+00:00 app[web.1]: at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:429:16)
2017-03-14T20:15:05.776685+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:319:22)
2017-03-14T20:15:05.776685+00:00 app[web.1]: at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:463:5)
2017-03-14T20:15:05.776686+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-03-14T20:15:05.776687+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-03-14T20:15:05.776688+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2017-03-14T20:15:05.776689+00:00 app[web.1]: at TCP.onread (net.js:548:20)
2017-03-14T20:15:05.776688+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:134:10)
2017-03-14T20:15:05.851998+00:00 heroku[web.1]: Process exited with status 1
2017-03-14T20:15:05.849610+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-14T20:15:05.850669+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-14T20:15:09.046484+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-03-14T20:15:12.712501+00:00 heroku[web.1]: Process exited with status 1
2017-03-14T20:15:12.632012+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:319:22)
2017-03-14T20:15:12.630846+00:00 app[web.1]:
2017-03-14T20:15:12.632015+00:00 app[web.1]: at TCP.onread (net.js:548:20)
2017-03-14T20:15:12.630864+00:00 app[web.1]: events.js:160
2017-03-14T20:15:12.632013+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-03-14T20:15:12.630866+00:00 app[web.1]: throw er; // Unhandled 'error' event
2017-03-14T20:15:12.632014+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2017-03-14T20:15:12.630866+00:00 app[web.1]: ^
2017-03-14T20:15:12.632015+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:134:10)
2017-03-14T20:15:12.632008+00:00 app[web.1]: MongoError: Authentication failed.
2017-03-14T20:15:12.632013+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-03-14T20:15:12.632010+00:00 app[web.1]: at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
2017-03-14T20:15:12.632011+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:483:72
2017-03-14T20:15:12.632011+00:00 app[web.1]: at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:429:16)
2017-03-14T20:15:12.632012+00:00 app[web.1]: at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:463:5)
2017-03-14T20:15:12.729762+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-14T20:15:54.013766+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thawing-chamber-22079.herokuapp.com request_id=13034e5e-049a-42c6-a0b7-37c3f769d416 fwd="209.49.17.173" dyno= connect= service= status=503 bytes= protocol=https
2017-03-14T20:15:54.509374+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=thawing-chamber-22079.herokuapp.com request_id=f0c7f03e-db03-4efc-ba84-cb21e79d31d8 fwd="209.49.17.173" dyno= connect= service= status=503 bytes= protocol=https
2017-03-14T20:18:26.328705+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thawing-chamber-22079.herokuapp.com request_id=59a6218c-44ef-4c69-b712-173c6b438782 fwd="209.49.17.173" dyno= connect= service= status=503 bytes= protocol=https
2017-03-14T20:18:26.757058+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=thawing-chamber-22079.herokuapp.com request_id=59c15c21-f2b2-4266-b5c7-2c7367e4c136 fwd="209.49.17.173" dyno= connect= service= status=503 bytes= protocol=https
2017-03-14T20:42:56.872743+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-14T20:43:00.417848+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-03-14T20:43:03.592709+00:00 app[web.1]:
2017-03-14T20:43:03.592728+00:00 app[web.1]: events.js:160
2017-03-14T20:43:03.592729+00:00 app[web.1]: throw er; // Unhandled 'error' event
2017-03-14T20:43:03.592730+00:00 app[web.1]: ^
2017-03-14T20:43:03.593930+00:00 app[web.1]: MongoError: Authentication failed.
2017-03-14T20:43:03.593932+00:00 app[web.1]: at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
2017-03-14T20:43:03.593933+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:483:72
2017-03-14T20:43:03.593933+00:00 app[web.1]: at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:429:16)
2017-03-14T20:43:03.593934+00:00 app[web.1]: at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:463:5)
2017-03-14T20:43:03.593934+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:319:22)
2017-03-14T20:43:03.593935+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-03-14T20:43:03.593935+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-03-14T20:43:03.593936+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2017-03-14T20:43:03.593936+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:134:10)
2017-03-14T20:43:03.593937+00:00 app[web.1]: at TCP.onread (net.js:548:20)
2017-03-14T20:43:03.686941+00:00 heroku[web.1]: Process exited with status 1
2017-03-14T20:43:03.707557+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-14T21:40:18.936675+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-14T21:40:21.858760+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-03-14T21:40:25.337623+00:00 heroku[web.1]: Process exited with status 1
2017-03-14T21:40:25.209569+00:00 app[web.1]:
2017-03-14T21:40:25.209587+00:00 app[web.1]: events.js:160
2017-03-14T21:40:25.209589+00:00 app[web.1]: throw er; // Unhandled 'error' event
2017-03-14T21:40:25.209590+00:00 app[web.1]: ^
2017-03-14T21:40:25.211925+00:00 app[web.1]: MongoError: Authentication failed.
2017-03-14T21:40:25.211928+00:00 app[web.1]: at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
2017-03-14T21:40:25.211930+00:00 app[web.1]: at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:429:16)
2017-03-14T21:40:25.211929+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:483:72
2017-03-14T21:40:25.211931+00:00 app[web.1]: at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:463:5)
2017-03-14T21:40:25.211931+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:319:22)
2017-03-14T21:40:25.211932+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-03-14T21:40:25.211932+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-03-14T21:40:25.211933+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2017-03-14T21:40:25.211934+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:134:10)
2017-03-14T21:40:25.211934+00:00 app[web.1]: at TCP.onread (net.js:548:20)
2017-03-14T21:40:25.353825+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-14T23:09:56.515355+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-14T23:09:59.150824+00:00 heroku[web.1]: Starting process with command `node server.js`
2017-03-14T23:10:01.803320+00:00 heroku[web.1]: Process exited with status 1
2017-03-14T23:10:01.745328+00:00 app[web.1]:
2017-03-14T23:10:01.745344+00:00 app[web.1]: events.js:160
2017-03-14T23:10:01.745349+00:00 app[web.1]: throw er; // Unhandled 'error' event
2017-03-14T23:10:01.745349+00:00 app[web.1]: ^
2017-03-14T23:10:01.746159+00:00 app[web.1]: MongoError: Authentication failed.
2017-03-14T23:10:01.746161+00:00 app[web.1]: at Function.MongoError.create (/app/node_modules/mongodb-core/lib/error.js:31:11)
2017-03-14T23:10:01.746162+00:00 app[web.1]: at /app/node_modules/mongodb-core/lib/connection/pool.js:483:72
2017-03-14T23:10:01.746163+00:00 app[web.1]: at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:429:16)
2017-03-14T23:10:01.746163+00:00 app[web.1]: at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:463:5)
2017-03-14T23:10:01.746164+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:319:22)
2017-03-14T23:10:01.746165+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-03-14T23:10:01.746165+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-03-14T23:10:01.746166+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:176:18)
2017-03-14T23:10:01.746167+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:134:10)
2017-03-14T23:10:01.746167+00:00 app[web.1]: at TCP.onread (net.js:548:20)
2017-03-14T23:10:01.820453+00:00 heroku[web.1]: State changed from starting to crashed
Related
I'm new in nodeJS,
I want upload my backend on Heroku to my Frontend but I got this Error
This code work in localhost,
I Added NODE_DATABASE in Heroku
"Error MongoNetworkError", "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch"
my app.js
const dotenv = require("dotenv").load();
const express = require("express");
const session = require("express-session");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const passport = require("passport");
const morgan = require("morgan");
const cors = require("cors");
const LocalStrategy = require("passport-local").Strategy;
const routes = require("./routes");
const User = require("./models/User");
const MongoStore = require("connect-mongo")(session);
const PORT = process.env.PORT || 9000;
const app = express();
app.use(bodyParser.json());
app.use(morgan("combined"));
app.use(cors());
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
app.use(
session({
secret: "Norbert",
resave: false,
saveUninitialized: true,
cookie: { maxAge: 86400000 },
store: new MongoStore({
mongooseConnection: mongoose.connection,
}),
})
);
app.use(express.urlencoded({ extended: true }));
app.use(passport.initialize());
app.use(passport.session());
mongoose.connect(process.env.NODE_DATABASE, { useNewUrlParser: true });
const conn = mongoose.connection;
conn.on("error", console.error.bind(console, "connection error:"));
conn.once("open", () => {
console.log("Connected to mlab database!");
app.listen(PORT, () => console.log(`App is listening on port ${PORT}!`));
app.use("/api", routes);
});
heroku logs
2020-08-20T10:05:53.139695+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:05:54.067319+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:05:55.810360+00:00 app[web.1]: connection error: MongoNetworkError: connection 5 to cluster0-shard-00-01.ho4na.mongodb.net:27017 closed
2020-08-20T10:05:55.810364+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:05:55.810364+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:05:55.810365+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:05:55.810365+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:05:55.810365+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:05:55.810369+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:05:55.810369+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:05:55.810369+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:05:55.810370+00:00 app[web.1]: }
2020-08-20T10:05:55.828088+00:00 app[web.1]: [nodemon] clean exit - waiting for changes before restart
2020-08-20T10:06:50.472320+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:06:50.496970+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:06:50.575809+00:00 heroku[web.1]: Process exited with status 137
2020-08-20T10:06:50.607171+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:06:50.609395+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-20T10:06:55.049996+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-20T10:06:57.284172+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2020-08-20T10:06:57.284202+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2020-08-20T10:06:57.687757+00:00 app[web.1]:
2020-08-20T10:06:57.687800+00:00 app[web.1]: > notes#1.0.0 start /app
2020-08-20T10:06:57.687801+00:00 app[web.1]: > nodemon --exec babel-node src/app.js
2020-08-20T10:06:57.687802+00:00 app[web.1]:
2020-08-20T10:06:58.012979+00:00 app[web.1]: [nodemon] 1.18.10
2020-08-20T10:06:58.014501+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2020-08-20T10:06:58.015004+00:00 app[web.1]: [nodemon] watching: *.*
2020-08-20T10:06:58.015615+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:06:59.007296+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:07:01.309982+00:00 app[web.1]: connection error: MongoNetworkError: connection 5 to cluster0-shard-00-00.ho4na.mongodb.net:27017 closed
2020-08-20T10:07:01.309998+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:07:01.310000+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:07:01.310000+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:07:01.310001+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:07:01.310001+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:07:01.310002+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:07:01.310002+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:07:01.310003+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:07:01.310003+00:00 app[web.1]: }
2020-08-20T10:07:01.340827+00:00 app[web.1]: [nodemon] clean exit - waiting for changes before restart
2020-08-20T10:07:55.450102+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:07:55.473020+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:07:55.500784+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2020-08-20T10:07:55.575750+00:00 heroku[web.1]: Process exited with status 22
2020-08-20T10:07:55.620964+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:10:09.137371+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=favnoteback.herokuapp.com request_id=111d6959-56ad-4449-9ba6-77fa7a426577 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:10:10.310013+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=favnoteback.herokuapp.com request_id=dba1ddd0-36d1-44f7-886b-1e22f8ca526d fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:11:20.182121+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=favnoteback.herokuapp.com request_id=fc425fd1-dcce-49e3-b9af-eae31c9d35f5 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:11:20.884144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=favnoteback.herokuapp.com request_id=e81ab2e2-c476-494f-a2f3-2c5a3281fc55 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:19:21.000000+00:00 app[api]: Build started by user myemail#gmail.com
2020-08-20T10:19:47.820767+00:00 app[api]: Deploy f6a0950d by user myemail#gmail.com
2020-08-20T10:19:47.820767+00:00 app[api]: Release v14 created by user myemail#gmail.com
2020-08-20T10:19:48.014495+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-20T10:19:49.000000+00:00 app[api]: Build succeeded
2020-08-20T10:19:52.366993+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-20T10:19:55.049310+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2020-08-20T10:19:55.049332+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2020-08-20T10:19:55.560928+00:00 app[web.1]:
2020-08-20T10:19:55.560950+00:00 app[web.1]: > notes#1.0.0 start /app
2020-08-20T10:19:55.560951+00:00 app[web.1]: > nodemon --exec babel-node src/app.js
2020-08-20T10:19:55.560951+00:00 app[web.1]:
2020-08-20T10:19:55.989648+00:00 app[web.1]: [nodemon] 1.18.10
2020-08-20T10:19:55.990902+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2020-08-20T10:19:55.991361+00:00 app[web.1]: [nodemon] watching: *.*
2020-08-20T10:19:55.991938+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:19:57.234412+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:19:58.962557+00:00 app[web.1]: the options [useUnifiedTopology] is not supported
2020-08-20T10:19:59.745897+00:00 app[web.1]: /app/node_modules/mongodb/lib/operations/mongo_client_ops.js:474
2020-08-20T10:19:59.745912+00:00 app[web.1]: throw err;
2020-08-20T10:19:59.745913+00:00 app[web.1]: ^
2020-08-20T10:19:59.745913+00:00 app[web.1]:
2020-08-20T10:19:59.745914+00:00 app[web.1]: MongoNetworkError: connection 9 to cluster0-shard-00-00.ho4na.mongodb.net:27017 closed
2020-08-20T10:19:59.745915+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:19:59.745916+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:19:59.745917+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:19:59.745917+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:19:59.745917+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:19:59.745918+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:19:59.745918+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:19:59.745919+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:19:59.745919+00:00 app[web.1]: }
2020-08-20T10:19:59.763100+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2020-08-20T10:20:52.546213+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:20:52.568907+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:20:52.691301+00:00 heroku[web.1]: Process exited with status 137
2020-08-20T10:20:52.742514+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:20:52.744625+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-20T10:20:56.145248+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-20T10:20:58.152568+00:00 app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2020-08-20T10:20:58.152590+00:00 app[web.1]: Recommending WEB_CONCURRENCY=1
2020-08-20T10:20:58.572627+00:00 app[web.1]:
2020-08-20T10:20:58.572655+00:00 app[web.1]: > notes#1.0.0 start /app
2020-08-20T10:20:58.572656+00:00 app[web.1]: > nodemon --exec babel-node src/app.js
2020-08-20T10:20:58.572656+00:00 app[web.1]:
2020-08-20T10:20:58.948432+00:00 app[web.1]: [nodemon] 1.18.10
2020-08-20T10:20:58.949669+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2020-08-20T10:20:58.950054+00:00 app[web.1]: [nodemon] watching: *.*
2020-08-20T10:20:58.950608+00:00 app[web.1]: [nodemon] starting `babel-node src/app.js`
2020-08-20T10:20:59.976088+00:00 app[web.1]: Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
2020-08-20T10:21:01.137742+00:00 app[web.1]: the options [useUnifiedTopology] is not supported
2020-08-20T10:21:01.921790+00:00 app[web.1]: connection error: MongoNetworkError: connection 8 to cluster0-shard-00-02.ho4na.mongodb.net:27017 closed
2020-08-20T10:21:01.921802+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:21:01.921803+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:21:01.921804+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:21:01.921804+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:21:01.921805+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:21:01.921805+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:21:01.921806+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:21:01.921806+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:21:01.921807+00:00 app[web.1]: }
2020-08-20T10:21:01.933176+00:00 app[web.1]: /app/node_modules/mongodb/lib/operations/mongo_client_ops.js:474
2020-08-20T10:21:01.933178+00:00 app[web.1]: throw err;
2020-08-20T10:21:01.933178+00:00 app[web.1]: ^
2020-08-20T10:21:01.933179+00:00 app[web.1]:
2020-08-20T10:21:01.933180+00:00 app[web.1]: MongoNetworkError: connection 11 to cluster0-shard-00-02.ho4na.mongodb.net:27017 closed
2020-08-20T10:21:01.933180+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:276:9)
2020-08-20T10:21:01.933181+00:00 app[web.1]: at Object.onceWrapper (events.js:422:26)
2020-08-20T10:21:01.933181+00:00 app[web.1]: at TLSSocket.emit (events.js:327:22)
2020-08-20T10:21:01.933182+00:00 app[web.1]: at net.js:674:12
2020-08-20T10:21:01.933182+00:00 app[web.1]: at TCP.done (_tls_wrap.js:563:7) {
2020-08-20T10:21:01.933182+00:00 app[web.1]: name: 'MongoNetworkError',
2020-08-20T10:21:01.933183+00:00 app[web.1]: errorLabels: [ 'TransientTransactionError' ],
2020-08-20T10:21:01.933183+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-08-20T10:21:01.933183+00:00 app[web.1]: }
2020-08-20T10:21:01.960242+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2020-08-20T10:21:47.512311+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=favnoteback.herokuapp.com request_id=a0b75780-abfa-4727-99b4-cdf9bc42bb62 fwd="85.221.154.50" dyno= connect= service= status=503 bytes=
protocol=https
2020-08-20T10:21:56.438920+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-08-20T10:21:56.456159+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-08-20T10:21:56.480098+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2020-08-20T10:21:56.526046+00:00 heroku[web.1]: Process exited with status 22
2020-08-20T10:21:56.561169+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-20T10:21:57.783155+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=favnoteback.herokuapp.com request_id=aa62afa9-ae33-40b3-9b54-d25bed03c5fa fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
2020-08-20T10:21:58.572293+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=favnoteback.herokuapp.com request_id=afed98ae-b48b-4d0f-944e-551cdc703571 fwd="85.221.154.50" dyno= connect= service= status=503 bytes= protocol=https
I'm very appreciated if whose help me in this Error
OK I found resolve
application could not connect with mongodb,
resolve is add 0.0.0.0/0 ip on white list in mongodb
Listen method
let port = process.env.PORT;
if (port == null || port == "")
{port = 3000; }
app.listen(port);
app.listen(port, function() {
console.log("Server has started successfully!");
});
Procfile
web: node app.js
Package.json
{
"name": "todolist-v1",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"engines": {
"node": "12.18.0"
},
"dependencies": {
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"lodash": "^4.17.19",
"mongoose": "^5.9.26"
}
}
After deploying the app on heroku
This is being displayed when I am visiting the specified address in my terminal
After logging the error in terminal
$ heroku logs --tail
2020-08-06T17:58:14.031722+00:00 app[api]: Initial release by user saadahmad728#gmail.com
2020-08-06T17:58:14.031722+00:00 app[api]: Release v1 created by user saadahmad728#gmail.com
2020-08-06T17:58:14.344269+00:00 app[api]: Enable Logplex by user saadahmad728#gmail.com
2020-08-06T17:58:14.344269+00:00 app[api]: Release v2 created by user saadahmad728#gmail.com
2020-08-06T18:27:53.000000+00:00 app[api]: Build started by user saadahmad728#gmail.com
2020-08-06T18:28:08.541198+00:00 app[api]: Deploy 08926525 by user saadahmad728#gmail.com
2020-08-06T18:28:08.541198+00:00 app[api]: Release v3 created by user saadahmad728#gmail.com
2020-08-06T18:28:08.555631+00:00 app[api]: Scaled to web#1:Free by user saadahmad728#gmail.com
2020-08-06T18:28:09.000000+00:00 app[api]: Build succeeded
2020-08-06T18:28:12.043887+00:00 heroku[web.1]: Starting process with command `node app.js`
2020-08-06T18:28:15.554606+00:00 app[web.1]: events.js:292
2020-08-06T18:28:15.554621+00:00 app[web.1]: throw er; // Unhandled 'error' event
2020-08-06T18:28:15.554622+00:00 app[web.1]: ^
2020-08-06T18:28:15.554622+00:00 app[web.1]:
2020-08-06T18:28:15.554622+00:00 app[web.1]: Error: listen EADDRINUSE: address already in use :::43074
2020-08-06T18:28:15.554623+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1313:16)
2020-08-06T18:28:15.554623+00:00 app[web.1]: at listenInCluster (net.js:1361:12)
2020-08-06T18:28:15.554624+00:00 app[web.1]: at Server.listen (net.js:1447:7)
2020-08-06T18:28:15.554624+00:00 app[web.1]: at Function.listen (/app/node_modules/express/lib/application.js:618:24)
2020-08-06T18:28:15.554625+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:146:5)
2020-08-06T18:28:15.554625+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-08-06T18:28:15.554626+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-08-06T18:28:15.554626+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-08-06T18:28:15.554626+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-08-06T18:28:15.554627+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
2020-08-06T18:28:15.554627+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-08-06T18:28:15.554628+00:00 app[web.1]: Emitted 'error' event on Server instance at:
2020-08-06T18:28:15.554628+00:00 app[web.1]: at emitErrorNT (net.js:1340:8)
2020-08-06T18:28:15.554629+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21) {
2020-08-06T18:28:15.554629+00:00 app[web.1]: code: 'EADDRINUSE',
2020-08-06T18:28:15.554629+00:00 app[web.1]: errno: 'EADDRINUSE',
2020-08-06T18:28:15.554630+00:00 app[web.1]: syscall: 'listen',
2020-08-06T18:28:15.554630+00:00 app[web.1]: address: '::',
2020-08-06T18:28:15.554631+00:00 app[web.1]: port: 43074
2020-08-06T18:28:15.554631+00:00 app[web.1]: }
2020-08-06T18:28:15.643665+00:00 heroku[web.1]: Process exited with status 1
2020-08-06T18:28:15.719470+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-06T18:28:15.721915+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-06T18:28:18.063014+00:00 heroku[web.1]: Starting process with command `node app.js`
2020-08-06T18:28:20.963100+00:00 app[web.1]: events.js:292
2020-08-06T18:28:20.963109+00:00 app[web.1]: throw er; // Unhandled 'error' event
2020-08-06T18:28:20.963110+00:00 app[web.1]: ^
2020-08-06T18:28:20.963110+00:00 app[web.1]:
2020-08-06T18:28:20.963110+00:00 app[web.1]: Error: listen EADDRINUSE: address already in use :::131252020-08-06T18:28:20.963111+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1313:16)
2020-08-06T18:28:20.963111+00:00 app[web.1]: at listenInCluster (net.js:1361:12)2020-08-06T18:28:20.963111+00:00 app[web.1]: at Server.listen (net.js:1447:7)
2020-08-06T18:28:20.963111+00:00 app[web.1]: at Function.listen (/app/node_modules/express/lib/application.js:618:24)
2020-08-06T18:28:20.963112+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:146:5)
2020-08-06T18:28:20.963112+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)2020-08-06T18:28:20.963112+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-08-06T18:28:20.963113+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)2020-08-06T18:28:20.963117+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-08-06T18:28:20.963118+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)2020-08-06T18:28:20.963118+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-08-06T18:28:20.963118+00:00 app[web.1]: Emitted 'error' event on Server instance at:2020-08-06T18:28:20.963118+00:00 app[web.1]: at emitErrorNT (net.js:1340:8)
2020-08-06T18:28:20.963119+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21) {2020-08-06T18:28:20.963119+00:00 app[web.1]: code: 'EADDRINUSE',
2020-08-06T18:28:20.963119+00:00 app[web.1]: errno: 'EADDRINUSE',2020-08-06T18:28:20.963119+00:00 app[web.1]: syscall: 'listen',
2020-08-06T18:28:20.963119+00:00 app[web.1]: address: '::',2020-08-06T18:28:20.963120+00:00 app[web.1]: port: 13125
2020-08-06T18:28:20.963120+00:00 app[web.1]: }2020-08-06T18:28:21.012655+00:00 heroku[web.1]: Process exited with status 1
2020-08-06T18:28:21.056282+00:00 heroku[web.1]: State changed from starting to crashed2020-08-06T18:28:29.979419+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=glacial-garden-21504.herokuapp.com request_id=20e2dc90-d336-4df4-bf85-921f061bc1c8 fwd="112.79.249.195" dyno= connect= service= status=503 bytes= protocol=https
2020-08-06T18:28:30.848729+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-garden-21504.herokuapp.com request_id=f2e74a20-48ae-4dfc-bffb-ef19fd6a3d20 fwd="112.79.249.195" dyno= connect= service= status=503 bytes= protocol=https
2020-08-06T18:41:35.920695+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=glacial-garden-21504.herokuapp.com request_id=f9d2e233-529d-4b69-993c-72d1cb0a07f0 fwd="112.79.249.195" dyno= connect= service= status=503 bytes= protocol=https
2020-08-06T18:41:36.396586+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-garden-21504.herokuapp.com request_id=2b55782b-9c16-4577-a425-2197e1d089c3 fwd="112.79.249.195" dyno= connect= service= status=503 bytes= protocol=https
2020-08-06T18:49:42.523761+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-06T18:49:45.975358+00:00 heroku[web.1]: Starting process with command `node app.js`
2020-08-06T18:49:49.958428+00:00 heroku[web.1]: Process exited with status 1
2020-08-06T18:49:50.010996+00:00 heroku[web.1]: State changed from starting to crashed2020-08-06T18:49:49.868123+00:00 app[web.1]: events.js:292
2020-08-06T18:49:49.868203+00:00 app[web.1]: throw er; // Unhandled 'error' event2020-08-06T18:49:49.868208+00:00 app[web.1]: ^2020-08-06T18:49:49.868208+00:00 app[web.1]: 2020-08-06T18:49:49.868217+00:00 app[web.1]: Error: listen EADDRINUSE: address already in use :::41212
2020-08-06T18:49:49.868217+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1313:16)2020-08-06T18:49:49.868217+00:00 app[web.1]: at listenInCluster (net.js:1361:12)2020-08-06T18:49:49.868218+00:00 app[web.1]: at Server.listen (net.js:1447:7)2020-08-06T18:49:49.868222+00:00 app[web.1]: at Function.listen (/app/node_modules/express/lib/application.js:618:24)
2020-08-06T18:49:49.868222+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:146:5)2020-08-06T18:49:49.868222+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)2020-08-06T18:49:49.868223+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)2020-08-06T18:49:49.868223+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-08-06T18:49:49.868223+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)2020-08-06T18:49:49.868227+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)2020-08-06T18:49:49.868228+00:00 app[web.1]: at internal/main/run_main_module.js:17:472020-08-06T18:49:49.868228+00:00 app[web.1]: Emitted 'error' event on Server instance at:
2020-08-06T18:49:49.868228+00:00 app[web.1]: at emitErrorNT (net.js:1340:8)
2020-08-06T18:49:49.868228+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21) {
2020-08-06T18:49:49.868232+00:00 app[web.1]: code: 'EADDRINUSE',
2020-08-06T18:49:49.868232+00:00 app[web.1]: errno: 'EADDRINUSE',
2020-08-06T18:49:49.868233+00:00 app[web.1]: syscall: 'listen',
2020-08-06T18:49:49.868233+00:00 app[web.1]: address: '::',
2020-08-06T18:49:49.868233+00:00 app[web.1]: port: 41212
2020-08-06T18:49:49.868233+00:00 app[web.1]: }
2020-08-06T19:17:44.469614+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=glacial-garden-21504.herokuapp.com request_id=84715403-a9ea-414d-ad04-e1b2b712f20b fwd="112.79.249.195" dyno= connect= service= status=503 bytes= protocol=https
2020-08-06T19:17:45.793877+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=glacial-garden-21504.herokuapp.com request_id=1e9c96ca-dab7-4ea5-b870-62b4be7194fc fwd="112.79.249.195" dyno= connect= service= status=503 bytes= protocol=https
^CTerminate batch job (Y/N)? ^C
The above message is being displayed
I am new to heroku and don't know much about it. It would we greatly appreciated if anyone walks me through the path of successfull app deployment.
You are calling app.listen two times. That isn't necessary. The EADDRINUSE error code tells you that you are trying to listen on an address that is already in use, which is what will happen if you call app.listen two times. Just call it once, like so:
let port = process.env.PORT;
if (port == null || port == "") { port = 3000; }
app.listen(port, function() {
console.log("Server has started successfully!");
});
I created the app using express and MongoDB. When I run the app locally it runs perfectly.I created a PostDB database on MongoDB atlas and generated and got connection string.I want to deploy this app using heroku but I don't why it gives this error.Please help me. Thanks in advance.
This is my connection string:
mongoose.connect("\mongodb+srv://Admin:minnu#mongodb01.irdlb.mongodb.net/PostDB",{useNewUrlParser:true,useCreateIndex:true, useUnifiedTopology: true},function(err,db){
if (err) {
console.log('Unable to connect to the server. Please start the server. Error:', err);
} else {
console.log('Connected to Server successfully!');
}});
This is the error I get:
2020-07-22T13:10:59.614060+00:00 app[web.1]: commonWireVersion: null
2020-07-22T13:10:59.614061+00:00 app[web.1]: }
2020-07-22T13:10:59.614061+00:00 app[web.1]: }
2020-07-22T13:10:59.631071+00:00 app[web.1]: Unable to connect to the server. Please start the server. Error: MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
2020-07-22T13:10:59.631074+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:828:32)
2020-07-22T13:10:59.631075+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:335:15)
2020-07-22T13:10:59.631076+00:00 app[web.1]: at Object.<anonymous> (/app/Models/User.js:2:10)
2020-07-22T13:10:59.631076+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T13:10:59.631077+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T13:10:59.631077+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T13:10:59.631078+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T13:10:59.631078+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-22T13:10:59.631079+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-07-22T13:10:59.631079+00:00 app[web.1]: at Object.<anonymous> (/app/Routes/Posts.js:6:12)
2020-07-22T13:10:59.631079+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T13:10:59.631080+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T13:10:59.631080+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T13:10:59.631081+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T13:10:59.631081+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-22T13:10:59.631081+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18) {
2020-07-22T13:10:59.631082+00:00 app[web.1]: reason: TopologyDescription {
2020-07-22T13:10:59.631082+00:00 app[web.1]: type: 'Single',
2020-07-22T13:10:59.631083+00:00 app[web.1]: setName: null,
2020-07-22T13:10:59.631083+00:00 app[web.1]: maxSetVersion: null,
2020-07-22T13:10:59.631083+00:00 app[web.1]: maxElectionId: null,
2020-07-22T13:10:59.631084+00:00 app[web.1]: servers: Map { 'localhost:27017' => [ServerDescription] },
2020-07-22T13:10:59.631084+00:00 app[web.1]: stale: false,
2020-07-22T13:10:59.631085+00:00 app[web.1]: compatible: true,
2020-07-22T13:10:59.631085+00:00 app[web.1]: compatibilityError: null,
2020-07-22T13:10:59.631086+00:00 app[web.1]: logicalSessionTimeoutMinutes: null,
2020-07-22T13:10:59.631086+00:00 app[web.1]: heartbeatFrequencyMS: 10000,
2020-07-22T13:10:59.631086+00:00 app[web.1]: localThresholdMS: 15,
2020-07-22T13:10:59.631087+00:00 app[web.1]: commonWireVersion: null
2020-07-22T13:10:59.631087+00:00 app[web.1]: }
2020-07-22T13:10:59.631087+00:00 app[web.1]: }
2020-07-22T13:11:29.817201+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T13:43:44.978055+00:00 heroku[web.1]: Idling
2020-07-22T13:43:44.980176+00:00 heroku[web.1]: State changed from up to down
2020-07-22T13:43:46.293776+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-22T13:43:46.385591+00:00 heroku[web.1]: Process exited with status 143
2020-07-22T15:23:20.000000+00:00 app[api]: Build started by user mamadgiaishwarya#gmail.com
2020-07-22T15:23:41.274124+00:00 app[api]: Deploy 9e2202b9 by user mamadgiaishwarya#gmail.com
2020-07-22T15:23:41.274124+00:00 app[api]: Release v9 created by user mamadgiaishwarya#gmail.com
2020-07-22T15:23:41.454375+00:00 heroku[web.1]: State changed from down to starting
2020-07-22T15:23:42.000000+00:00 app[api]: Build succeeded
2020-07-22T15:23:43.755247+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T15:23:46.020199+00:00 app[web.1]:
2020-07-22T15:23:46.020218+00:00 app[web.1]: > ejs-challenge#1.0.0 start /app
2020-07-22T15:23:46.020219+00:00 app[web.1]: > node app.js
2020-07-22T15:23:46.020219+00:00 app[web.1]:
2020-07-22T15:23:46.753513+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-07-22T15:23:46.753525+00:00 app[web.1]: designed for a production environment, as it will leak
2020-07-22T15:23:46.753554+00:00 app[web.1]: memory, and will not scale past a single process.
2020-07-22T15:23:46.770376+00:00 app[web.1]: Server started on port 3000
2020-07-22T15:23:47.305407+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T15:23:48.056394+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:23:48.059001+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:24:25.538134+00:00 heroku[router]: at=info method=GET path="/" host=shielded-citadel-75286.herokuapp.com request_id=a2276768-c8b4-4937-a8f9-feb2e1cc9d00 fwd="106.200.146.62" dyno=web.1 connect=0ms service=1360ms status=200 bytes=4199 protocol=https
2020-07-22T15:24:26.201469+00:00 heroku[router]: at=info method=GET path="/css/styles.css" host=shielded-citadel-75286.herokuapp.com request_id=1d330f4c-66fd-407c-a8ed-57ba80507318 fwd="106.200.146.62" dyno=web.1 connect=1ms service=9ms status=200 bytes=2179 protocol=https
2020-07-22T15:24:26.284481+00:00 heroku[router]: at=info method=GET path="/images/logo.jpg" host=shielded-citadel-75286.herokuapp.com request_id=96a94f69-2984-4b7f-8e5e-1ae6f12493e6 fwd="106.200.146.62" dyno=web.1 connect=0ms service=11ms status=200 bytes=8897 protocol=https
2020-07-22T15:24:26.318935+00:00 heroku[router]: at=info method=GET path="/images/butterfly.gif" host=shielded-citadel-75286.herokuapp.com request_id=f54f11ef-31a4-4fdf-ad7f-c5d47c354afb fwd="106.200.146.62" dyno=web.1 connect=0ms service=45ms status=200 bytes=687572 protocol=https
2020-07-22T15:24:51.370552+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=shielded-citadel-75286.herokuapp.com request_id=396f3ab9-b44b-4432-888e-792eb45268e2 fwd="106.200.146.62" dyno=web.1 connect=0ms service=5ms status=404 bytes=394 protocol=https
2020-07-22T15:26:13.000000+00:00 app[api]: Build started by user mamadgiaishwarya#gmail.com
2020-07-22T15:26:35.089490+00:00 app[api]: Release v10 created by user mamadgiaishwarya#gmail.com
2020-07-22T15:26:35.089490+00:00 app[api]: Deploy 7fd231d2 by user mamadgiaishwarya#gmail.com
2020-07-22T15:26:36.000000+00:00 app[api]: Build succeeded
2020-07-22T15:26:36.726907+00:00 heroku[web.1]: Restarting
2020-07-22T15:26:36.741521+00:00 heroku[web.1]: State changed from up to starting
2020-07-22T15:26:37.654962+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-22T15:26:37.782161+00:00 heroku[web.1]: Process exited with status 143
2020-07-22T15:26:39.941929+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T15:26:42.451886+00:00 app[web.1]:
2020-07-22T15:26:42.451908+00:00 app[web.1]: > ejs-challenge#1.0.0 start /app
2020-07-22T15:26:42.451908+00:00 app[web.1]: > node app.js
2020-07-22T15:26:42.451909+00:00 app[web.1]:
2020-07-22T15:26:43.528332+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-07-22T15:26:43.528343+00:00 app[web.1]: designed for a production environment, as it will leak
2020-07-22T15:26:43.528344+00:00 app[web.1]: memory, and will not scale past a single process.
2020-07-22T15:26:43.537025+00:00 app[web.1]: Server started on port 3000
2020-07-22T15:26:43.977021+00:00 heroku[web.1]: State changed from starting to up
2020-07-22T15:26:44.829130+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:26:44.831445+00:00 app[web.1]: Connected to Server successfully!
2020-07-22T15:28:23.000000+00:00 app[api]: Build started by user mamadgiaishwarya#gmail.com
2020-07-22T15:28:45.263212+00:00 app[api]: Deploy c7cbd9d0 by user mamadgiaishwarya#gmail.com
2020-07-22T15:28:45.263212+00:00 app[api]: Release v11 created by user mamadgiaishwarya#gmail.com
2020-07-22T15:28:45.446526+00:00 heroku[web.1]: Restarting
2020-07-22T15:28:45.448387+00:00 heroku[web.1]: State changed from up to starting
2020-07-22T15:28:46.000000+00:00 app[api]: Build succeeded
2020-07-22T15:28:46.651703+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-22T15:28:46.746865+00:00 heroku[web.1]: Process exited with status 143
2020-07-22T15:28:49.098450+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T15:28:51.924571+00:00 app[web.1]:
2020-07-22T15:28:51.924589+00:00 app[web.1]: > ejs-challenge#1.0.0 start /app
2020-07-22T15:28:51.924589+00:00 app[web.1]: > node app.js
2020-07-22T15:28:51.924589+00:00 app[web.1]:
2020-07-22T15:28:52.898117+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-07-22T15:28:52.898161+00:00 app[web.1]: designed for a production environment, as it will leak
2020-07-22T15:28:52.898162+00:00 app[web.1]: memory, and will not scale past a single process.
2020-07-22T15:28:52.905188+00:00 app[web.1]: Server started on port 3000
2020-07-22T15:28:53.428020+00:00 heroku[web.1]: State changed from starting to up
I think you have a mistake in your connection string.
According to MongoDB docs, connection string should start with mongodb://, not with the leading \ in the front.
I also recommend you to use Promises or Async/Await for your connections, like the following snippet below:
// Start connection via Mongoose.
mongoose
.connect(YOUR_CONNECTION_STRING, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
})
.then(() => {
console.log('Database connected successfully!');
})
.catch((err) => {
console.log('Error connecting with error code:', err);
});
app.listen(PORT, () => {
console.log('Server starts at port...');
}
It makes code much easier to read.
Alternatively, do you have any exceptions that you do not catch before connecting to the database? It might bubble up and crash your database connection for security reasons.
I have now spent a couple of days searching for reasons why this is happening and have tried to make sure all file names are consistent both locally and in the git push since I hear that Heroku can be funny about this.
The app works absolutely fine on my local server I should add.
Here is the heroku logs coming from when I restart the app on heroku:
2019-03-04T21:42:46.527650+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-04T21:42:49.314540+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-03-04T21:42:50.921757+00:00 app[web.1]: { NODE_HOME: '/app/.heroku/node',
2019-03-04T21:42:50.921775+00:00 app[web.1]: NODE_ENV: 'production',
2019-03-04T21:42:50.921776+00:00 app[web.1]: WEB_MEMORY: '512',
2019-03-04T21:42:50.921777+00:00 app[web.1]: DYNO: 'web.1',
2019-03-04T21:42:50.921779+00:00 app[web.1]: PWD: '/app',
2019-03-04T21:42:50.921780+00:00 app[web.1]: HOME: '/app',
2019-03-04T21:42:50.921781+00:00 app[web.1]: PORT: '51817',
2019-03-04T21:42:50.921782+00:00 app[web.1]: MEMORY_AVAILABLE: '512',
2019-03-04T21:42:50.921783+00:00 app[web.1]: WEB_CONCURRENCY: '1',
2019-03-04T21:42:50.921784+00:00 app[web.1]: SHLVL: '1',
2019-03-04T21:42:50.921785+00:00 app[web.1]: PATH:
2019-03-04T21:42:50.921787+00:00 app[web.1]: '/app/.heroku/node/bin:/app/.heroku/yarn/bin:/usr/local/bin:/usr/bin:/bin:/app/bin:/app/node_modules/.bin',
2019-03-04T21:42:50.921788+00:00 app[web.1]: PS1:
2019-03-04T21:42:50.921790+00:00 app[web.1]: '\\[\\033[01;34m\\]\\w\\[\\033[00m\\] \\[\\033[01;32m\\]$ \\[\\033[00m\\]',
2019-03-04T21:42:50.921791+00:00 app[web.1]: _: '/app/.heroku/node/bin/node',
2019-03-04T21:42:50.921792+00:00 app[web.1]: COUDINARY_NAME: 'djbcg1deo',
2019-03-04T21:42:50.921793+00:00 app[web.1]: COUDINARY_API_KEY: '571183338823141',
2019-03-04T21:42:50.921794+00:00 app[web.1]: COUDINARY_API_SECRET: 'DkJ_3UsH7DLTsHHwmD68AMUYJzY',
2019-03-04T21:42:50.921795+00:00 app[web.1]: DB_URI: 'node-js-blog' }
2019-03-04T21:42:51.723033+00:00 app[web.1]: internal/modules/cjs/loader.js:582
2019-03-04T21:42:51.723058+00:00 app[web.1]: throw err;
2019-03-04T21:42:51.723060+00:00 app[web.1]: ^
2019-03-04T21:42:51.723061+00:00 app[web.1]:
2019-03-04T21:42:51.723063+00:00 app[web.1]: Error: Cannot find module './controllers/createPost'
2019-03-04T21:42:51.723066+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
2019-03-04T21:42:51.723068+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:506:25)
2019-03-04T21:42:51.723069+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:636:17)
2019-03-04T21:42:51.723071+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2019-03-04T21:42:51.723073+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:14:30)
2019-03-04T21:42:51.723074+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:688:30)
2019-03-04T21:42:51.723076+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
2019-03-04T21:42:51.723078+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:598:32)
2019-03-04T21:42:51.723079+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
2019-03-04T21:42:51.723081+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:529:3)
2019-03-04T21:42:51.723082+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
2019-03-04T21:42:51.723084+00:00 app[web.1]: at startup (internal/bootstrap/node.js:285:19)
2019-03-04T21:42:51.723086+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
2019-03-04T21:42:51.789482+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-04T21:42:51.770169+00:00 heroku[web.1]: Process exited with status 1
2019-03-04T21:43:12.736446+00:00 heroku[run.9030]: Client connection closed. Sending SIGHUP to all processes
2019-03-04T21:43:13.319723+00:00 heroku[run.9030]: State changed from up to complete
2019-03-04T21:43:13.297680+00:00 heroku[run.9030]: Process exited with status 129
2019-03-04T21:43:16.063306+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=james-node-blog.herokuapp.com request_id=b16a486a-239e-4bc4-9673-4f24febd9265 fwd="82.6.200.12" dyno= connect= service= status=503 bytes= protocol=https
2019-03-04T21:43:17.018561+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=james-node-blog.herokuapp.com request_id=63cc1508-3943-4251-b424-674186d84e76 fwd="82.6.200.12" dyno= connect= service= status=503 bytes= protocol=https
Also, the code can be found on my Github repo here:
https://github.com/jameslevine/Nodejs-Blog
I would greatly appreciate some pointers if anyone has any since I am going round in circles at this point.
Thanks in advance!
Update: Resolved 2 errors. First one was the filename change and the second was the fact that .gitignore didn't include the node_modules file. Now app gives this log, which indicates it is no longer crashing. However, I still can't see the app by clicking on Live App on Heroku. Any help there?
I have included logs below:
2019-03-05T08:59:41.441061+00:00 heroku[web.1]: Restarting
2019-03-05T08:59:41.444978+00:00 heroku[web.1]: State changed from up to starting
2019-03-05T08:59:42.400893+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-03-05T08:59:42.520869+00:00 heroku[web.1]: Process exited with status 143
2019-03-05T08:59:43.970483+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-03-05T08:59:45.929838+00:00 app[web.1]: { NODE_HOME: '/app/.heroku/node',
2019-03-05T08:59:45.929860+00:00 app[web.1]: NODE_ENV: 'production',
2019-03-05T08:59:45.929862+00:00 app[web.1]: WEB_MEMORY: '512',
2019-03-05T08:59:45.929863+00:00 app[web.1]: DYNO: 'web.1',
2019-03-05T08:59:45.929865+00:00 app[web.1]: PWD: '/app',
2019-03-05T08:59:45.929867+00:00 app[web.1]: HOME: '/app',
2019-03-05T08:59:45.929868+00:00 app[web.1]: PORT: '54093',
2019-03-05T08:59:45.929869+00:00 app[web.1]: MEMORY_AVAILABLE: '512',
2019-03-05T08:59:45.929870+00:00 app[web.1]: WEB_CONCURRENCY: '1',
2019-03-05T08:59:45.929871+00:00 app[web.1]: SHLVL: '1',
2019-03-05T08:59:45.929873+00:00 app[web.1]: PATH:
2019-03-05T08:59:45.929874+00:00 app[web.1]: '/app/.heroku/node/bin:/app/.heroku/yarn/bin:/usr/local/bin:/usr/bin:/bin:/app/bin:/app/node_modules/.bin',
2019-03-05T08:59:45.929875+00:00 app[web.1]: PS1:
2019-03-05T08:59:45.929877+00:00 app[web.1]: '\\[\\033[01;34m\\]\\w\\[\\033[00m\\] \\[\\033[01;32m\\]$ \\[\\033[00m\\]',
2019-03-05T08:59:45.929878+00:00 app[web.1]: _: '/app/.heroku/node/bin/node',
2019-03-05T08:59:45.929879+00:00 app[web.1]: COUDINARY_NAME: 'djbcg1deo',
2019-03-05T08:59:45.929880+00:00 app[web.1]: COUDINARY_API_KEY: '571183338823141',
2019-03-05T08:59:45.929881+00:00 app[web.1]: COUDINARY_API_SECRET: 'DkJ_3UsH7DLTsHHwmD68AMUYJzY',
2019-03-05T08:59:45.929882+00:00 app[web.1]: DB_URI: 'node-js-blog' }
2019-03-05T08:59:46.787139+00:00 app[web.1]: Tue, 05 Mar 2019 08:59:46 GMT express-session deprecated undefined resave option; provide resave option at index.js:38:9
2019-03-05T08:59:46.787355+00:00 app[web.1]: Tue, 05 Mar 2019 08:59:46 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at index.js:38:9
2019-03-05T08:59:46.795789+00:00 app[web.1]: (node:4) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
2019-03-05T08:59:46.796700+00:00 app[web.1]: App listing on port 54093
2019-03-05T08:59:46.804363+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
2019-03-05T08:59:46.804367+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:564:11)
2019-03-05T08:59:46.804369+00:00 app[web.1]: at Pool.emit (events.js:182:13)
2019-03-05T08:59:46.804370+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:317:12)
2019-03-05T08:59:46.804372+00:00 app[web.1]: at Object.onceWrapper (events.js:273:13)
2019-03-05T08:59:46.804373+00:00 app[web.1]: at Connection.emit (events.js:182:13)
2019-03-05T08:59:46.804375+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:246:50)
2019-03-05T08:59:46.804377+00:00 app[web.1]: at Object.onceWrapper (events.js:273:13)
2019-03-05T08:59:46.804378+00:00 app[web.1]: at Socket.emit (events.js:182:13)
2019-03-05T08:59:46.804380+00:00 app[web.1]: at emitErrorNT (internal/streams/destroy.js:82:8)
2019-03-05T08:59:46.804382+00:00 app[web.1]: at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
2019-03-05T08:59:46.804384+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:63:19)
2019-03-05T08:59:46.804474+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)
2019-03-05T08:59:46.804552+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.
2019-03-05T08:59:47.581487+00:00 heroku[web.1]: State changed from starting to up
2019-03-05T09:00:21.698023+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=james-node-blog.herokuapp.com request_id=55c8cc21-6544-4e4c-800f-62eac6ed8034 fwd="62.30.226.42" dyno=web.1 connect=2ms service=30000ms status=503 bytes=0 protocol=https
2019-03-05T09:01:18.887286+00:00 heroku[router]: at=error code=H15 desc="Idle connection" method=GET path="/favicon.ico" host=james-node-blog.herokuapp.com request_id=ccfeba5b-3105-423c-87f6-edfe9ba86584 fwd="62.30.226.42" dyno=web.1 connect=1ms service=55036ms status=503 bytes= protocol=https
Any ideas why it is now not showing live? I am just beginning to research this and think it is something to do with the server not starting but thought I would update on progress as I go along.
I think it's just a typo, you're trying to require createPost in index.js:14 and the file is actually called createpost.js
Error: Cannot find module './controllers/createPost'
It's weird, though, that it's working locally.
My app works locally. I added all that I thought was necessary for Heroku
Procfile
web: node app.js
package.json
{
"name": "HipsterMatch",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "nodemon app.js"
},
"dependencies": {
"express": "3.1.0",
"jade": "*",
"mongodb": "*",
"nodemon": "0.7.10",
"passport": "*",
"passport-local": "*",
"passport-facebook": "*",
"mongoose": "~3.6.4",
"connect-flash": "*"
},
"engines": {
"node": "0.10.1",
"npm": "1.3.14"
}
}
Here are my logs
2013-12-27T08:40:29.457548+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=hipsterlove.herokuapp.com fwd="162.205.69.18" dyno= connect= service= status=503 bytes=
2013-12-27T08:44:38.166741+00:00 heroku[api]: Add mongohq:sandbox add-on by jgallardo720#gmail.com
2013-12-27T08:44:38.186021+00:00 heroku[api]: Release v5 created by jgallardo720#gmail.com
2013-12-27T08:44:38.327041+00:00 heroku[web.1]: State changed from crashed to starting
2013-12-27T08:44:40.396197+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-12-27T08:44:42.090303+00:00 app[web.1]: Express server listening on port 37441
2013-12-27T08:44:42.092470+00:00 app[web.1]:
2013-12-27T08:44:42.092672+00:00 app[web.1]: events.js:72
2013-12-27T08:44:42.092911+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-12-27T08:44:42.092911+00:00 app[web.1]: ^
2013-12-27T08:44:42.095509+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-12-27T08:44:42.095509+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-12-27T08:44:42.095509+00:00 app[web.1]: at EventEmitter.emit (events.js:106:17)
2013-12-27T08:44:42.095509+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-12-27T08:44:42.095509+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
2013-12-27T08:44:42.095509+00:00 app[web.1]: at EventEmitter.emit (events.js:98:17)
2013-12-27T08:44:42.095509+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-12-27T08:44:42.095509+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-12-27T08:44:42.095509+00:00 app[web.1]: at net.js:426:14
2013-12-27T08:44:43.403162+00:00 heroku[web.1]: Process exited with status 8
2013-12-27T08:44:43.421294+00:00 heroku[web.1]: State changed from starting to crashed
2013-12-27T08:45:03.209570+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=hipsterlove.herokuapp.com fwd="162.205.69.18" dyno= connect= service= status=503 bytes=
2013-12-27T08:47:32.961418+00:00 heroku[api]: Add papertrail:choklad add-on by jgallardo720#gmail.com
2013-12-27T08:47:33.079955+00:00 heroku[api]: Release v6 created by jgallardo720#gmail.com
2013-12-27T08:47:33.710788+00:00 heroku[web.1]: State changed from crashed to starting
2013-12-27T08:47:36.186033+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-12-27T08:47:37.958627+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-12-27T08:47:37.958627+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-12-27T08:47:37.958627+00:00 app[web.1]: at EventEmitter.emit (events.js:106:17)
2013-12-27T08:47:37.954398+00:00 app[web.1]: ^
2013-12-27T08:47:37.949510+00:00 app[web.1]: Express server listening on port 32125
2013-12-27T08:47:37.952974+00:00 app[web.1]:
2013-12-27T08:47:37.953554+00:00 app[web.1]: events.js:72
2013-12-27T08:47:37.954045+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-12-27T08:47:37.958627+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-12-27T08:47:37.958627+00:00 app[web.1]: at EventEmitter.emit (events.js:98:17)
2013-12-27T08:47:37.958627+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-12-27T08:47:37.958627+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-12-27T08:47:37.958627+00:00 app[web.1]: at net.js:426:14
2013-12-27T08:47:37.958627+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
2013-12-27T08:47:39.133359+00:00 heroku[web.1]: State changed from starting to crashed
2013-12-27T08:47:39.134204+00:00 heroku[web.1]: State changed from crashed to starting
2013-12-27T08:47:39.120176+00:00 heroku[web.1]: Process exited with status 8
2013-12-27T08:47:41.463835+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-12-27T08:47:42.782433+00:00 app[web.1]: Express server listening on port 7709
2013-12-27T08:47:42.784187+00:00 app[web.1]:
2013-12-27T08:47:42.784508+00:00 app[web.1]: events.js:72
2013-12-27T08:47:42.784983+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-12-27T08:47:42.784983+00:00 app[web.1]: ^
2013
-12-27T08:47:42.787164+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-12-27T08:47:42.787164+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-12-27T08:47:42.787164+00:00 app[web.1]: at EventEmitter.emit (events.js:106:17)
2013-12-27T08:47:42.787164+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-12-27T08:47:42.787164+00:00 app[web.1]: at EventEmitter.emit (events.js:98:17)
2013-12-27T08:47:42.787164+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-12-27T08:47:42.787164+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-12-27T08:47:42.787164+00:00 app[web.1]: at net.js:426:14
2013-12-27T08:47:42.787164+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
2013-12-27T08:47:44.091837+00:00 heroku[web.1]: Process exited with status 8
2013-12-27T08:47:44.093316+00:00 heroku[web.1]: State changed from starting to crashed
2013-12-27T08:50:30+00:00 heroku[slug-compiler]: Slug compilation started
2013-12-27T08:50:55.506146+00:00 heroku[api]: Deploy 36c405b by jgallardo720#gmail.com
2013-12-27T08:50:55.532599+00:00 heroku[api]: Release v7 created by jgallardo720#gmail.com
2013-12-27T08:50:55+00:00 heroku[slug-compiler]: Slug compilation finished
2013-12-27T08:50:55.924898+00:00 heroku[web.1]: State changed from crashed to starting
2013-12-27T08:50:57.601471+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-12-27T08:50:58.821299+00:00 app[web.1]: Express server listening on port 44602
2013-12-27T08:50:58.823409+00:00 app[web.1]: events.js:72
2013-12-27T08:50:58.823687+00:00 app[web.1]: ^
2013-12-27T08:50:58.823080+00:00 app[web.1]:
2013-12-27T08:50:58.823687+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-12-27T08:50:58.826090+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-12-27T08:50:58.826090+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-12-27T08:50:58.826090+00:00 app[web.1]: at EventEmitter.emit (events.js:98:17)
2013-12-27T08:50:58.826090+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-12-27T08:50:58.826090+00:00 app[web.1]: at EventEmitter.emit (events.js:106:17)
2013-12-27T08:50:58.826090+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-12-27T08:50:58.826090+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-12-27T08:50:58.826090+00:00 app[web.1]: at net.js:426:14
2013-12-27T08:50:58.826090+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
2013-12-27T08:50:59.977120+00:00 heroku[web.1]: Process exited with status 8
2013-12-27T08:50:59.998919+00:00 heroku[web.1]: State changed from starting to crashed
2013-12-27T08:57:32.833792+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=hipsterlove.herokuapp.com fwd="174.251.209.112" dyno= connect= service= status=503 bytes=
2013-12-27T09:01:35.385263+00:00 heroku[web.1]: Starting process with command `node app.js`
2013-12-27T09:01:36.760608+00:00 app[web.1]: events.js:72
2013-12-27T09:01:36.758539+00:00 app[web.1]: Express server listening on port 4749
2013-12-27T09:01:36.760891+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-12-27T09:01:36.760257+00:00 app[web.1]:
2013-12-27T09:01:36.761120+00:00 app[web.1]: ^
2013-12-27T09:01:36.763625+00:00 app[web.1]: at EventEmitter.emit (events.js:98:17)
2013-12-27T09:01:36.763625+00:00 app[web.1]: at EventEmitter.emit (events.js:106:17)
2013-12-27T09:01:36.763625+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-12-27T09:01:36.763625+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-12-27T09:01:36.763625+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-12-27T09:01:36.763625+00:00 app[web.1]: at net.js:426:14
2013-12-27T09:01:36.763625+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
2013-12-27T09:01:36.763625+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-12-27T09:01:36.763625+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-12-27T09:01:37.955733+00:00 heroku[web.1]: Process exited with status 8
2013-12-27T09:01:37.987115+00:00 heroku[web.1]: State changed from starting to crashed
2013-12-27T09:01:33.253022+00:00 heroku[web.1]: State changed from crashed to starting
It looks like in prod you are referencing your local mongoDB instance:
Error: failed to connect to [localhost:27017]
I imagine you've hardcoded these values...
The recommended way of handling connection strings like this that change from environment to environment is to use environment variables (http://12factor.net/config).
So you'll need to do the following (if you haven't already).
1) Set up a mongo instance in the cloud (MongoHQ, mongoLab, etc) (heroku makes this fairly easy).
2) If heroku hasn't set the env variables for the connection strings you'll need to do that.
To list your env vars (enter this on the command line):
heroku config -a name_of_your_heroku_app
To set your env vars:
heroku config:set MONGO_URL=somethingGoesHere -a name_of_your_heroku_app
Then in your node code you can reference that value like so:
var url = process.env.MONGO_URL;
To set your env variables locally, create a .env file in the root of your app. Running foreman start will run your procfile as well as loading the .env variables into memory.