NodeJS app deployed on heroku issue - not retrieving data from database - node.js

I'm having an issue with my full-stack application, (MySQL-Express-React-NodeJS). I have deployed it to Heroku everything is working except the pages that are connected to get or post to ClearDB MySQL database! Any advises or hints on something that I might have forgot to do? I'm also using the ClearDB add-on from Heroku if that helps.
server.js:
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
const http = require("http");
const server = http.createServer(app);
const connection = require("./app/Models/database");
// require user the route
const user = require("./app/routes/user");
// require the doctor route
const doctor = require("./app/routes/doctor");
// require the question route
const questions = require("./app/routes/questions.js");
// require the schedule route
const schedule = require("./app/routes/schedule");
const appointement = require("./app/routes/appointment");
const socket = require("socket.io");
const io = socket(server);
app.use(cors());
// set the port
const port = process.env.PORT || 5000;
// parse requests of content-type - application/json
app.use(bodyParser.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// define the user router
app.use("/users", user);
app.use("/doctor", doctor);
app.use("/questions", questions);
app.use("/schedule", schedule);
app.use("/appointment", appointement);
app.use(function (error, req, res, next) {
if (error instanceof SyntaxError) {
//Handle SyntaxError here.
return res.status(500).send({ data: "Invalid data" });
} else {
next();
}
});
const peers = {};
io.on("connection", (socket) => {
//
if (!peers[socket.id]) {
peers[socket.id] = socket.id;
}
socket.emit("yourID", socket.id); // allows you to emit custom events on the server and client
io.sockets.emit("allUsers", peers); //will send to all the clients ......socket.broadcast.emit will send the message to all the other clients except the newly created connection
socket.on("disconnect", () => {
delete peers[socket.id]; //after the user leave the room
});
socket.on("callUser", (data) => {
io.to(data.userToCall).emit("hello", {
signal: data.signalData,
from: data.from,
}); //io.to('some room').emit('some event');
});
socket.on("acceptCall", (data) => {
io.to(data.to).emit("callAccepted", data.signal);
});
});
//test route
app.get("/test", function (req, res) {
res.send( "test");
});
app.listen(port, () => {
console.log(`Server is Running on port ${port}`);
});
Heroku logs:
2021-01-04T18:46:17.729977+00:00 heroku[web.1]: Restarting
2021-01-04T18:46:17.732430+00:00 heroku[web.1]: State changed from up to starting
2021-01-04T18:46:18.729190+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-01-04T18:46:18.801647+00:00 heroku[web.1]: Process exited with status 143
2021-01-04T18:46:53.555253+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-04T18:46:57.234794+00:00 app[web.1]:
2021-01-04T18:46:57.234819+00:00 app[web.1]: > server#1.0.0 start
2021-01-04T18:46:57.234819+00:00 app[web.1]: > node server.js
2021-01-04T18:46:57.234820+00:00 app[web.1]:
2021-01-04T18:46:58.471423+00:00 app[web.1]: /app/server.js:61
2021-01-04T18:46:58.471444+00:00 app[web.1]: console.log(`Server is Running in port:${port}`);
2021-01-04T18:46:58.471446+00:00 app[web.1]: ^
2021-01-04T18:46:58.471446+00:00 app[web.1]:
2021-01-04T18:46:58.471447+00:00 app[web.1]: ReferenceError: port is not defined
2021-01-04T18:46:58.471447+00:00 app[web.1]: at Server.<anonymous> (/app/server.js:61:44)
2021-01-04T18:46:58.471447+00:00 app[web.1]: at Object.onceWrapper (node:events:482:28)
2021-01-04T18:46:58.471448+00:00 app[web.1]: at Server.emit (node:events:388:22)
2021-01-04T18:46:58.471448+00:00 app[web.1]: at emitListeningNT (node:net:1329:10)
2021-01-04T18:46:58.471449+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:79:21)
2021-01-04T18:46:58.502509+00:00 app[web.1]: npm ERR! code 1
2021-01-04T18:46:58.503140+00:00 app[web.1]: npm ERR! path /app
2021-01-04T18:46:58.509321+00:00 app[web.1]: npm ERR! command failed
2021-01-04T18:46:58.509747+00:00 app[web.1]: npm ERR! command sh -c node server.js
2021-01-04T18:46:58.536286+00:00 app[web.1]:
2021-01-04T18:46:58.542292+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-04T18:46:58.542507+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T18_46_58_510Z-debug.log
2021-01-04T18:46:58.614100+00:00 heroku[web.1]: Process exited with status 1
2021-01-04T18:46:58.673495+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-04T18:46:58.677305+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-04T18:47:24.050526+00:00 heroku[web.1]: Starting process with command `npm start`
2021-01-04T18:47:27.323089+00:00 app[web.1]:
2021-01-04T18:47:27.323103+00:00 app[web.1]: > server#1.0.0 start
2021-01-04T18:47:27.323103+00:00 app[web.1]: > node server.js
2021-01-04T18:47:27.323104+00:00 app[web.1]:
2021-01-04T18:47:27.950882+00:00 app[web.1]: /app/server.js:61
2021-01-04T18:47:27.950900+00:00 app[web.1]: console.log(`Server is Running in port:${port}`);
2021-01-04T18:47:27.950901+00:00 app[web.1]: ^
2021-01-04T18:47:27.950903+00:00 app[web.1]:
2021-01-04T18:47:27.950903+00:00 app[web.1]: ReferenceError: port is not defined
2021-01-04T18:47:27.950903+00:00 app[web.1]: at Server.<anonymous> (/app/server.js:61:44)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at Object.onceWrapper (node:events:482:28)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at Server.emit (node:events:388:22)
2021-01-04T18:47:27.950904+00:00 app[web.1]: at emitListeningNT (node:net:1329:10)
2021-01-04T18:47:27.950905+00:00 app[web.1]: at processTicksAndRejections (node:internal/process/task_queues:79:21)
2021-01-04T18:47:27.970852+00:00 app[web.1]: npm ERR! code 1
2021-01-04T18:47:27.971425+00:00 app[web.1]: npm ERR! path /app
2021-01-04T18:47:27.976210+00:00 app[web.1]: npm ERR! command failed
2021-01-04T18:47:27.976596+00:00 app[web.1]: npm ERR! command sh -c node server.js
2021-01-04T18:47:27.987341+00:00 app[web.1]:
2021-01-04T18:47:27.987620+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-01-04T18:47:27.987792+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T18_47_27_977Z-debug.log
2021-01-04T18:47:28.067423+00:00 heroku[web.1]: Process exited with status 1
2021-01-04T18:47:28.111585+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-04T18:48:09.000000+00:00 app[api]: Build started by user ishaqatfarah#gmail.com
2021-01-04T18:50:08.503349+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=41eadebc-6547-4735-975c-47f07af41139 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:13.899678+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=f9c641f9-30c1-4ef7-a184-0d286cecf4c0 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:37.722683+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=a897151b-2c68-440d-bb39-877ad0e80b3c fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:38.328012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=3b546e46-3812-4a18-8f78-f585c9f3e740 fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:44.226260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=speakout-2.herokuapp.com request_id=df1690f0-5e59-4105-aae7-857d2a2ef8ff fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https
2021-01-04T18:50:44.682096+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=speakout-2.herokuapp.com request_id=d4bee131-4929-4f80-96dd-d829a6c53bde fwd="46.185.242.147" dyno= connect= service= status=503 bytes= protocol=https

Related

is there a way to solve heroku 503 deploying error?

I would like to thank you guys in advance. so I am having issues opening my express server after I have deployed it on Heroku. The issue is I keep on getting the error below and I hope someone can please help me.
2023-02-06T09:34:31.419072+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2023-02-06T09:34:31.419234+00:00 app[web.1]: npm ERR! errno 1
2023-02-06T09:34:31.419978+00:00 app[web.1]: npm ERR! server#1.0.0 start: node server.js
2023-02-06T09:34:31.420062+00:00 app[web.1]: npm ERR! Exit status 1
2023-02-06T09:34:31.420152+00:00 app[web.1]: npm ERR!
2023-02-06T09:34:31.420229+00:00 app[web.1]: npm ERR! Failed at the server#1.0.0 start script.
2023-02-06T09:34:31.420301+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2023-02-06T09:34:31.428635+00:00 app[web.1]:
2023-02-06T09:34:31.428714+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2023-02-06T09:34:31.428770+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2023-02-06T09_34_31_420Z-debug.log
2023-02-06T09:34:31.607388+00:00 heroku[web.1]: Process exited with status 1
2023-02-06T09:34:31.670514+00:00 heroku[web.1]: State changed from starting to crashed
2023-02-06T09:34:57.360088+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thewrightlogistic.herokuapp.com request_id=45a256da-ca0f-4af1-86a6-a7fc81112803 fwd="98.174.153.51" dyno= connect= service= status=503 bytes= protocol=https
2023-02-06T09:34:57.360088+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thewrightlogistic.herokuapp.com request_id=45a256da-ca0f-4af1-86a6-a7fc81112803 fwd="98.174.153.51" dyno= connect= service= status=503 bytes= protocol=https
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser')
const mongoose = require('./database')
const middleware = require('./middleware')
const cors = require('cors')
const app = express();
const contactRouter = require('./routes/contactRoutes');
const authRouter = require('./routes/authRoutes');
const userRouter = require('./routes/userRoutes');
// const dashboardRouter = require('./routes/dashboard');
// view engine setup
app.set('view engine', 'ejs' );
// STATIC FILES
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static('public'));
app.use(cors())
// post contact route
app.use('/auth',authRouter );
app.use('/users',userRouter );
app.use('/contact',contactRouter );
// app.use('/dashboard',dashboardRouter );
// FOR PRODUCTION
app.listen(process.env.PORT || 8080, () => {
console.log(`Listening on port 8080`)
})

(Heroku + node js + mongoDB ) Getting error when deploying, mainly time out error. Can somebody tell how to resolve

I am trying to deploy in heroku, but i am getting errors. Can somebody tell me where i did mistake.
I tried many things but didnt worked.
Here is the code for app.js
const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const _ = require("lodash");
const app = express();
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));
mongoose.connect("mongodb+srv://Teja-Sruthi:varanasi#cluster0.rp0nmhh.mongodb.net/toDoListDB",function(err){
if(err)
console.log("Here is the error");
else
console.log("Successfully connected to MongoDB");
});
const itemsSchema = new mongoose.Schema({
name:String
});
const listSchema ={
name:String,
items:[itemsSchema]
};
const Item = mongoose.model("Item",itemsSchema);
const List = mongoose.model("List",listSchema);
const item1 = new Item({
name: "Complete this course"
});
const item2 = new Item({
name: "Complete RPA course"
});
const item3 = new Item({
name: "Learn Programming"
});
const defaultArray = [item1, item2, item3];
// Item.insertMany(defaultArray,function(err){
// if(err)
// console.log(err);
// else
// console.log("Successfully saved");
// });
app.get("/", function(req, res) {
Item.find(function(err,item){
if(err)
console.log("Error in finding ");
else{
if(item.length==0){
Item.insertMany(defaultArray,function(err){
if(err)
console.log("Error in inserting ");
else
console.log("Successfully saved");
});
return res.redirect("/");
}
}
res.render("list", {listTitle: "Today", newListItems: item});
})
});
app.post("/", function(req, res){
const itemName = req.body.newItem;
const title = req.body.list;
if(itemName!=""){
const item = new Item({
name: itemName,
});
if(title=="Today"){
item.save();
res.redirect("/");
}else{
List.findOne({name:title},function(err,matched){
matched.items.push(item);
matched.save();
res.redirect("/"+title);
});
}
}
else{
res.redirect("/"+title);
}
});
app.post("/delete",function(req,res){
const itemId = req.body.checkbox;
const itemName = req.body.itemName;
if(itemName=="Today"){
Item.findByIdAndRemove(itemId,function(err){
if(err)
console.log("Error in deleting")
else{
res.redirect("/");
}
});
}else{
List.findOneAndUpdate({name:itemName},{$pull:{items:{_id:itemId}}},function(err,result){
if(!err){
res.redirect("/"+itemName);
}
else {
console.log("error is from here");
}
});
}
});
app.get("/:value",function(req,res){
let listVal = _.capitalize(req.params.value);
const list1 = new List({
name: listVal,
items :defaultArray
});
List.findOne({name:listVal},function(err,getList){
if(err)
console.log("Error in the list");
else{
if(!getList){
list1.save();
res.redirect("/"+listVal);
}
else{
res.render("list",{listTitle:listVal, newListItems:getList.items});
}
}
});
});
app.get("/about", function(req, res){
res.render("about");
});
const port = 3000;
const host = '0.0.0.0';
app.listen(process.env.PORT || 3000, host, function() {
console.log("Server started on port 3000");
});
Procfile
worker: node app.js
First I used web, later in some stackoverflow post they suggested to use worker. So, I used it.
This is package.json
{
"name": "todolist-v1",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"engines": {
"node": "16.17.0",
"npm": "8.15.0"
},
"dependencies": {
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"lodash": "^4.17.21",
"mongoose": "^6.6.1"
},
"description": ""
}
These are the logs i got in used heroku logs command
2022-09-22T11:43:47.573252+00:00 heroku[web.1]: Starting process with command `npm start`
2022-09-22T11:43:48.020566+00:00 heroku[worker.1]: Starting process with command `node app.js`
2022-09-22T11:43:48.636966+00:00 heroku[worker.1]: State changed from starting to up
2022-09-22T11:43:49.398088+00:00 app[web.1]:
2022-09-22T11:43:49.398103+00:00 app[web.1]: > todolist-v1#1.0.0 start
2022-09-22T11:43:49.398103+00:00 app[web.1]: > node app.js
2022-09-22T11:43:49.398103+00:00 app[web.1]:
2022-09-22T11:43:49.914670+00:00 app[web.1]: Server started on port 3000
2022-09-22T11:43:50.376696+00:00 app[worker.1]: Server started on port 3000
2022-09-22T11:43:50.490534+00:00 heroku[web.1]: State changed from starting to up
2022-09-22T11:44:19.939658+00:00 app[web.1]: Here is the error
2022-09-22T11:44:20.402283+00:00 app[worker.1]: Here is the error
2022-09-22T11:44:25.544171+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=dry-oasis-02543.herokuapp.com request_id=8f66c999-2443-4fc3-a235-ee19ab2e1e19 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https
2022-09-22T11:44:36.038694+00:00 app[web.1]: Error in the list
2022-09-22T11:44:56.021923+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dry-oasis-02543.herokuapp.com request_id=9aad3faf-e16b-4d72-9017-d5adab63dcdd fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T11:49:05.000000+00:00 app[api]: Build started by user tejasruthivaranasi#gmail.com
2022-09-22T11:49:24.598076+00:00 app[api]: Deploy ccfe68fc by user tejasruthivaranasi#gmail.com
2022-09-22T11:49:24.598076+00:00 app[api]: Release v8 created by user tejasruthivaranasi#gmail.com
2022-09-22T11:49:25.191002+00:00 heroku[web.1]: Restarting
2022-09-22T11:49:25.206129+00:00 heroku[web.1]: State changed from up to starting
2022-09-22T11:49:25.241019+00:00 heroku[worker.1]: Restarting
2022-09-22T11:49:25.243739+00:00 heroku[worker.1]: State changed from up to starting
2022-09-22T11:49:25.931887+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2022-09-22T11:49:26.000000+00:00 app[api]: Build succeeded
2022-09-22T11:49:26.098641+00:00 heroku[web.1]: Process exited with status 143
2022-09-22T11:49:26.123725+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2022-09-22T11:49:26.312098+00:00 heroku[worker.1]: Process exited with status 143
2022-09-22T11:49:27.079784+00:00 heroku[web.1]: Starting process with command `npm start`
2022-09-22T11:49:27.344674+00:00 heroku[worker.1]: Starting process with command `node app.js`
2022-09-22T11:49:27.941719+00:00 heroku[worker.1]: State changed from starting to up
2022-09-22T11:49:28.759619+00:00 app[web.1]:
2022-09-22T11:49:28.759633+00:00 app[web.1]: > todolist-v1#1.0.0 start
2022-09-22T11:49:28.759633+00:00 app[web.1]: > node app.js
2022-09-22T11:49:28.759633+00:00 app[web.1]:
2022-09-22T11:49:29.100500+00:00 app[web.1]: Server started on port 3000
2022-09-22T11:49:29.242842+00:00 heroku[web.1]: State changed from starting to up
2022-09-22T11:49:29.509283+00:00 app[worker.1]: Server started on port 3000
2022-09-22T11:49:59.125117+00:00 app[web.1]: Here is the error
2022-09-22T11:49:59.539099+00:00 app[worker.1]: Here is the error
2022-09-22T11:50:01.519135+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=dry-oasis-02543.herokuapp.com request_id=b11dd120-7249-4193-900b-06e64dcb57a2 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T11:50:12.216527+00:00 app[web.1]: Error in the list
2022-09-22T11:50:32.201892+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dry-oasis-02543.herokuapp.com request_id=43ebca7f-343b-4ba7-b9af-b17f525b8211 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T11:51:25.684763+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=dry-oasis-02543.herokuapp.com request_id=1506f9ca-959b-464d-9452-6c012bc8f60e fwd="49.204.236.35" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T11:51:36.223978+00:00 app[web.1]: Error in the list
2022-09-22T11:51:56.213282+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dry-oasis-02543.herokuapp.com request_id=f5813669-3f1d-4333-bc6c-f4f2d0dd5b13 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T12:21:10.759124+00:00 heroku[web.1]: Idling
2022-09-22T12:21:10.764667+00:00 heroku[web.1]: State changed from up to down
2022-09-22T12:21:10.774495+00:00 heroku[worker.1]: Idling
2022-09-22T12:21:10.776324+00:00 heroku[worker.1]: State changed from up to down
2022-09-22T12:21:11.449023+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2022-09-22T12:21:11.643613+00:00 heroku[web.1]: Process exited with status 143
2022-09-22T12:21:12.711392+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2022-09-22T12:21:13.033420+00:00 heroku[worker.1]: Process exited with status 143
2022-09-22T12:22:59.026961+00:00 heroku[web.1]: Unidling
2022-09-22T12:22:59.034456+00:00 heroku[web.1]: State changed from down to starting
2022-09-22T12:22:59.069700+00:00 heroku[worker.1]: Unidling
2022-09-22T12:22:59.071316+00:00 heroku[worker.1]: State changed from down to starting
2022-09-22T12:23:01.147856+00:00 heroku[worker.1]: Starting process with command `node app.js`
2022-09-22T12:23:01.167784+00:00 heroku[web.1]: Starting process with command `npm start`
2022-09-22T12:23:01.741746+00:00 heroku[worker.1]: State changed from starting to up
2022-09-22T12:23:03.404493+00:00 app[worker.1]: Server started on port 3000
2022-09-22T12:23:03.564580+00:00 app[web.1]:
2022-09-22T12:23:03.564587+00:00 app[web.1]: > todolist-v1#1.0.0 start
2022-09-22T12:23:03.564588+00:00 app[web.1]: > node app.js
2022-09-22T12:23:03.564588+00:00 app[web.1]:
2022-09-22T12:23:04.268791+00:00 app[web.1]: Server started on port 3000
2022-09-22T12:23:04.584653+00:00 heroku[web.1]: State changed from starting to up
2022-09-22T12:23:33.451469+00:00 app[worker.1]: Here is the error
2022-09-22T12:23:34.310032+00:00 app[web.1]: Here is the error
2022-09-22T12:23:36.112393+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=dry-oasis-02543.herokuapp.com request_id=771ad4af-a2d0-4fe6-8fd8-a95259e627ea fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T12:23:46.556173+00:00 app[web.1]: Error in the list
2022-09-22T12:24:06.516346+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dry-oasis-02543.herokuapp.com request_id=af42aa9e-a35a-477d-97e7-a9252d8fd9f0 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T12:24:12.292521+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=dry-oasis-02543.herokuapp.com request_id=924bf97b-becb-4bf2-92f8-30923d1e62d9 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https
2022-09-22T12:24:23.687465+00:00 app[web.1]: Error in the list
2022-09-22T12:24:43.688408+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=dry-oasis-02543.herokuapp.com request_id=84fc8cc4-1aad-4fdf-be95-c8cd91b648ee fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2022-09-22T12:54:40.227336+00:00 heroku[web.1]: Idling
2022-09-22T12:54:40.232858+00:00 heroku[web.1]: State changed from up to down
2022-09-22T12:54:40.242617+00:00 heroku[worker.1]: Idling
2022-09-22T12:54:40.245598+00:00 heroku[worker.1]: State changed from up to down
2022-09-22T12:54:40.999737+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2022-09-22T12:54:41.244765+00:00 heroku[worker.1]: Process exited with status 143
2022-09-22T12:54:43.076058+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2022-09-22T12:54:43.355126+00:00 heroku[web.1]: Process exited with status 143
2022-09-22T13:06:03.062197+00:00 heroku[web.1]: Unidling
2022-09-22T13:06:03.066831+00:00 heroku[web.1]: State changed from down to starting
2022-09-22T13:06:03.118009+00:00 heroku[worker.1]: Unidling
2022-09-22T13:06:03.123303+00:00 heroku[worker.1]: State changed from down to starting
2022-09-22T13:06:05.208336+00:00 heroku[web.1]: Starting process with command `npm start`
2022-09-22T13:06:05.223738+00:00 heroku[worker.1]: Starting process with command `node app.js`
2022-09-22T13:06:05.898834+00:00 heroku[worker.1]: State changed from starting to up
2022-09-22T13:06:07.286374+00:00 app[web.1]:
2022-09-22T13:06:07.286485+00:00 app[web.1]: > todolist-v1#1.0.0 start
2022-09-22T13:06:07.286491+00:00 app[web.1]: > node app.js
2022-09-22T13:06:07.286492+00:00 app[web.1]:
2022-09-22T13:06:07.480766+00:00 app[worker.1]: Server started on port 3000
2022-09-22T13:06:07.798042+00:00 app[web.1]: Server started on port 3000
2022-09-22T13:06:08.202201+00:00 heroku[web.1]: State changed from starting to up
2022-09-22T13:06:37.514683+00:00 app[worker.1]: Here is the error
2022-09-22T13:06:37.839644+00:00 app[web.1]: Here is the error
2022-09-22T13:06:39.152554+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=dry-oasis-02543.herokuapp.com request_id=0a2548b5-c865-4d50-88ef-054bc6a5e1d4 fwd="49.204.236.35" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
I am trying this from long time. Please help.

Mern app working locally - 503 error on Heroku (H10-H13)

I have made a project through a course with Brad Traversy called contact keeper. It works fine locally on my machine and I get contact with the database.
Once I push it to Heroku I cant log in or register anymore. I get a 503 error (H10 & H13 errors from heroku) saying service unavailable when trying to hit those endpoints.
I have tried looking on similar threads but it does not work for me. I have added a procfile and checked through my package.json and it looks alright (from what I see).
The full repository can be found here: https://github.com/Dannus90/Contact_Keeper_MERN
const express = require('express');
const connectDB = require('./config/db');
const path = require('path');
const app = express();
// Connect Database
connectDB();
// Init Middleware
app.use(express.json({ extended: false }));
// Define Routes
app.use('/api/users', require('./routes/users'));
app.use('/api/auth', require('./routes/auth'));
app.use('/api/contacts', require('./routes/contacts'));
// Serve static assets in production
if (process.env.NODE_ENV === 'production') {
// Set static folder
app.use(express.static('client/build'));
app.get('*', (req, res) =>
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'))
);
}
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
In the picture below you can see where it fails. It is in the AuthState file when it tries to hit the endpoints.
The complete error log from heroku can be seen below:
2020-05-17T09:23:20.616623+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:23:50.230066+00:00 app[web.1]: connection <monitor> to 52.31.65.44:27017 closed
2020-05-17T09:23:50.240114+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:23:50.240313+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:23:50.241253+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:23:50.241374+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:23:50.241498+00:00 app[web.1]: npm ERR!
2020-05-17T09:23:50.241622+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:23:50.241760+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:23:50.249534+00:00 app[web.1]:
2020-05-17T09:23:50.249723+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:23:50.249843+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_23_50_242Z-debug.log
2020-05-17T09:23:50.311445+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:26:49.000000+00:00 app[api]: Build started by user persson.daniel.1990#gmail.com
2020-05-17T09:28:20.734327+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-17T09:28:20.461350+00:00 app[api]: Release v48 created by user persson.daniel.1990#gmail.com
2020-05-17T09:28:20.461350+00:00 app[api]: Deploy 502ce232 by user persson.daniel.1990#gmail.com
2020-05-17T09:28:21.000000+00:00 app[api]: Build succeeded
2020-05-17T09:28:30.543747+00:00 app[web.1]:
2020-05-17T09:28:30.543761+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2020-05-17T09:28:30.543761+00:00 app[web.1]: > node server.js
2020-05-17T09:28:30.543762+00:00 app[web.1]:
2020-05-17T09:28:31.157953+00:00 app[web.1]: Server started on port 13966
2020-05-17T09:28:32.044290+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:28:33.217189+00:00 heroku[router]: at=info method=GET path="/" host=afternoon-earth-34040.herokuapp.com request_id=ed1492f5-d053-4ecf-8a88-8561992f3403 fwd="78.82.2.105" dyno=web.1 connect=0ms service=11ms status=200 bytes=2626 protocol=https
2020-05-17T09:28:33.348570+00:00 heroku[router]: at=info method=GET path="/static/css/main.abec718a.chunk.css" host=afternoon-earth-34040.herokuapp.com request_id=410da44d-797f-4a41-bafe-f130118e8c6d fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=200 bytes=4578 protocol=https
2020-05-17T09:28:33.346039+00:00 heroku[router]: at=info method=GET path="/static/js/main.6e77bd50.chunk.js" host=afternoon-earth-34040.herokuapp.com request_id=018e556e-91d6-4944-bd6e-0c5b74ece68a fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=200 bytes=28978 protocol=https
2020-05-17T09:28:33.474881+00:00 heroku[router]: at=info method=GET path="/static/js/2.9c49eab7.chunk.js" host=afternoon-earth-34040.herokuapp.com request_id=5379490e-fd9b-47c1-b001-15e036784e2d fwd="78.82.2.105" dyno=web.1 connect=0ms service=10ms status=200 bytes=192222 protocol=https
2020-05-17T09:28:33.992494+00:00 heroku[router]: at=info method=GET path="/api/contacts" host=afternoon-earth-34040.herokuapp.com request_id=3684bbba-83b1-4d90-b9f8-d4ba7dedbc60 fwd="78.82.2.105" dyno=web.1 connect=0ms service=2ms status=401 bytes=257 protocol=https
2020-05-17T09:28:33.990977+00:00 heroku[router]: at=info method=GET path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=705c0086-3927-4e6f-b2dd-45ac9165e303 fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=401 bytes=257 protocol=https
2020-05-17T09:28:34.365542+00:00 heroku[router]: at=info method=GET path="/manifest.json" host=afternoon-earth-34040.herokuapp.com request_id=1f38b786-2c3d-411e-8aee-6862c40e77d4 fwd="78.82.2.105" dyno=web.1 connect=1ms service=6ms status=200 bytes=787 protocol=https
2020-05-17T09:28:34.483877+00:00 heroku[router]: at=info method=GET path="/logo192.png" host=afternoon-earth-34040.herokuapp.com request_id=65807958-8954-4332-8cab-dc4320e2cac8 fwd="78.82.2.105" dyno=web.1 connect=0ms service=2ms status=200 bytes=5622 protocol=https
2020-05-17T09:28:42.084546+00:00 heroku[router]: at=info method=GET path="/static/js/2.9c49eab7.chunk.js.map" host=afternoon-earth-34040.herokuapp.com request_id=d186f408-b227-4ce3-8f6d-2858c2b6b5a0 fwd="78.82.2.105" dyno=web.1 connect=0ms service=18ms status=200 bytes=624338 protocol=https
2020-05-17T09:28:42.056584+00:00 heroku[router]: at=info method=GET path="/static/css/main.abec718a.chunk.css" host=afternoon-earth-34040.herokuapp.com request_id=4ebde32e-fca4-4968-89d2-e10af56e5ad3 fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=304 bytes=238 protocol=https
2020-05-17T09:28:42.176331+00:00 heroku[router]: at=info method=GET path="/static/js/main.6e77bd50.chunk.js.map" host=afternoon-earth-34040.herokuapp.com request_id=22d537d1-9c6e-445b-985a-78f2319dd192 fwd="78.82.2.105" dyno=web.1 connect=0ms service=4ms status=200 bytes=61221 protocol=https
2020-05-17T09:28:42.289347+00:00 heroku[router]: at=info method=GET path="/static/css/main.abec718a.chunk.css.map" host=afternoon-earth-34040.herokuapp.com request_id=7418f08d-9c43-47e0-b2d3-2f2d23652356 fwd="78.82.2.105" dyno=web.1 connect=0ms service=2ms status=200 bytes=15892 protocol=https
2020-05-17T09:29:01.254923+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=82f5a82c-e065-4e9e-a284-a82ba86287d2 fwd="78.82.2.105" dyno=web.1 connect=0ms service=15877ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.362981+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:29:01.235846+00:00 app[web.1]: connection <monitor> to 54.72.107.147:27017 closed
2020-05-17T09:29:01.262738+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:29:01.263049+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:29:01.263998+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:29:01.264159+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:29:01.264337+00:00 app[web.1]: npm ERR!
2020-05-17T09:29:01.264484+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:29:01.264618+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:29:01.270789+00:00 app[web.1]:
2020-05-17T09:29:01.270997+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:29:01.271145+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_29_01_265Z-debug.log
2020-05-17T09:29:01.256625+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=0e0e84a4-257b-43bd-a31d-b97ebaed5a10 fwd="78.82.2.105" dyno=web.1 connect=0ms service=16031ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.256627+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=acbb4fdf-bf07-4668-886e-a253a3e0aee3 fwd="78.82.2.105" dyno=web.1 connect=0ms service=15442ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.257557+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=1a45a04e-0c1e-47ea-b796-7299db72f732 fwd="78.82.2.105" dyno=web.1 connect=0ms service=21480ms status=503 bytes=0 protocol=https
2020-05-17T09:29:01.257996+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/api/auth" host=afternoon-earth-34040.herokuapp.com request_id=2531aa80-5bf8-42e8-b620-ff9f2969ba1f fwd="78.82.2.105" dyno=web.1 connect=0ms service=15579ms status=503 bytes=0 protocol=https
2020-05-17T09:29:04.000000+00:00 app[api]: Build started by user persson.daniel.1990#gmail.com
2020-05-17T09:30:32.857023+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-17T09:30:32.560586+00:00 app[api]: Release v49 created by user persson.daniel.1990#gmail.com
2020-05-17T09:30:32.560586+00:00 app[api]: Deploy aba0d37e by user persson.daniel.1990#gmail.com
2020-05-17T09:30:34.000000+00:00 app[api]: Build succeeded
2020-05-17T09:30:44.786119+00:00 app[web.1]:
2020-05-17T09:30:44.786136+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2020-05-17T09:30:44.786137+00:00 app[web.1]: > node server.js
2020-05-17T09:30:44.786137+00:00 app[web.1]:
2020-05-17T09:30:45.574040+00:00 app[web.1]: Server started on port 52681
2020-05-17T09:30:46.081535+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:31:15.677435+00:00 app[web.1]: connection <monitor> to 52.31.65.44:27017 closed
2020-05-17T09:31:15.698356+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:31:15.698666+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:31:15.699733+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:31:15.699922+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:31:15.700135+00:00 app[web.1]: npm ERR!
2020-05-17T09:31:15.700312+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:31:15.700467+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:31:15.723946+00:00 app[web.1]:
2020-05-17T09:31:15.724237+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:31:15.724392+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_31_15_704Z-debug.log
2020-05-17T09:31:15.828237+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:35:10.524783+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-17T09:35:21.345206+00:00 app[web.1]:
2020-05-17T09:35:21.345238+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2020-05-17T09:35:21.345238+00:00 app[web.1]: > node server.js
2020-05-17T09:35:21.345239+00:00 app[web.1]:
2020-05-17T09:35:22.181653+00:00 app[web.1]: Server started on port 57715
2020-05-17T09:35:22.526258+00:00 heroku[web.1]: State changed from starting to up
2020-05-17T09:35:52.241989+00:00 app[web.1]: connection <monitor> to 54.72.107.147:27017 closed
2020-05-17T09:35:52.255501+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-05-17T09:35:52.256048+00:00 app[web.1]: npm ERR! errno 1
2020-05-17T09:35:52.257707+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2020-05-17T09:35:52.258009+00:00 app[web.1]: npm ERR! Exit status 1
2020-05-17T09:35:52.258313+00:00 app[web.1]: npm ERR!
2020-05-17T09:35:52.258505+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2020-05-17T09:35:52.258686+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-05-17T09:35:52.266384+00:00 app[web.1]:
2020-05-17T09:35:52.266689+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-05-17T09:35:52.266864+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-05-17T09_35_52_259Z-debug.log
2020-05-17T09:35:52.425747+00:00 heroku[web.1]: State changed from up to crashed
2020-05-17T09:37:40.075229+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-earth-34040.herokuapp.com request_id=b86ff65a-3c2f-4609-85ba-a75500f93e3a fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:40.189972+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-earth-34040.herokuapp.com request_id=d5b50b56-a5df-4d19-9c0f-6298c0dea421 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:42.254860+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=afternoon-earth-34040.herokuapp.com request_id=20cdf3b9-5883-4dcd-898a-03eb6ee20dc5 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:43.970046+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=afternoon-earth-34040.herokuapp.com request_id=dc0e7da8-46fa-4da1-bdb6-4814157e43a5 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
2020-05-17T09:37:44.242232+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-earth-34040.herokuapp.com request_id=53adb339-25bb-4bca-9b89-638035820973 fwd="78.82.2.105" dyno= connect= service= status=503 bytes= protocol=https
This is the code from my db file:
const mongoose = require("mongoose");
const config = require("config");
const db = config.get("mongoURI");
const connectDB = async () => {
try {
await mongoose.connect(db, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
});
console.log("MongoDB Connected");
} catch (err) {
console.error(err.message);
process.exit(1);
}
};
module.exports = connectDB;
This is the database (found in default and production.js):
{
"mongoURI": "mongodb+srv://Daniel123:Daniel123#contactkeeper-rjjr4.mongodb.net/test?retryWrites=true&w=majority",
"jwtSecret": "secret"
}
Solution for me for this problem (incase anyone else get the problem):
I whitelisted 0.0.0.0/0 on mongodb, set environmental variables on heroku and set them as an alternative for the db connect(same with jwtSecret in the config), since the config was ignored when pushing to heroku:
const mongoose = require("mongoose");
const config = require("config");
const db = config.get("mongoURI");
const connectDB = async () => {
try {
await mongoose.connect(db || process.env.mongoURI, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
});
console.log("MongoDB Connected");
} catch (err) {
console.error(err.message);
process.exit(1);
}
};
module.exports = connectDB;

Error deploying MERN application to Heroku

The app successfully deploys but when I try to open the app, I get the following error:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
I ran -heroku logs --tail and I get the following:
deons-mbp:shrinkURL deonchoi$ heroku logs --tail
2019-12-13T02:59:25.356685+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-13T02:59:25.356952+00:00 app[web.1]: npm ERR! errno 1
2019-12-13T02:59:25.357905+00:00 app[web.1]: npm ERR! backend#1.0.0 start: `node server.js`
2019-12-13T02:59:25.358057+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-13T02:59:25.358220+00:00 app[web.1]: npm ERR!
2019-12-13T02:59:25.358348+00:00 app[web.1]: npm ERR! Failed at the backend#1.0.0 start script.
2019-12-13T02:59:25.358480+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-13T02:59:25.362742+00:00 app[web.1]:
2019-12-13T02:59:25.362837+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-13T02:59:25.362931+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-13T02_59_25_359Z-debug.log
2019-12-13T02:59:25.446611+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-13T02:59:25.422394+00:00 heroku[web.1]: Process exited with status 1
2019-12-13T03:00:38.195196+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=99378587-a922-4ad8-8445-aca15eba268a fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:00:38.710170+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=ba6a84fe-9a4b-433d-a00d-1a6231e0317c fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:00:49.612623+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=7fb228bc-9e62-4526-a51e-feff9631e266 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:00:50.201204+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=ada57278-8d33-4569-b3e3-bad6b136a234 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:03:11.014926+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-13T03:03:13.149581+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-13T03:03:15.545496+00:00 app[web.1]:
2019-12-13T03:03:15.545520+00:00 app[web.1]: > backend#1.0.0 start /app
2019-12-13T03:03:15.545522+00:00 app[web.1]: > node server.js
2019-12-13T03:03:15.545524+00:00 app[web.1]:
2019-12-13T03:03:16.082886+00:00 app[web.1]:
2019-12-13T03:03:16.082936+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:541
2019-12-13T03:03:16.082939+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-12-13T03:03:16.082942+00:00 app[web.1]: ^
2019-12-13T03:03:16.086177+00:00 app[web.1]: Error [MongooseError]: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2019-12-13T03:03:16.086180+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:10:11)
2019-12-13T03:03:16.086183+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:541:11)
2019-12-13T03:03:16.086185+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:328:15)
2019-12-13T03:03:16.086187+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:16:10)
2019-12-13T03:03:16.086189+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-13T03:03:16.086191+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-13T03:03:16.086193+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-13T03:03:16.086195+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-13T03:03:16.086197+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
2019-12-13T03:03:16.086200+00:00 app[web.1]: at internal/main/run_main_module.js:17:11 {
2019-12-13T03:03:16.086203+00:00 app[web.1]: message: 'The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.',
2019-12-13T03:03:16.086205+00:00 app[web.1]: name: 'MongooseError'
2019-12-13T03:03:16.086207+00:00 app[web.1]: }
2019-12-13T03:03:16.092626+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-13T03:03:16.092996+00:00 app[web.1]: npm ERR! errno 1
2019-12-13T03:03:16.094046+00:00 app[web.1]: npm ERR! backend#1.0.0 start: `node server.js`
2019-12-13T03:03:16.094306+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-13T03:03:16.094539+00:00 app[web.1]: npm ERR!
2019-12-13T03:03:16.094740+00:00 app[web.1]: npm ERR! Failed at the backend#1.0.0 start script.
2019-12-13T03:03:16.094919+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-13T03:03:16.104750+00:00 app[web.1]:
2019-12-13T03:03:16.105020+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-13T03:03:16.105275+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-13T03_03_16_095Z-debug.log
2019-12-13T03:03:16.178860+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-13T03:03:16.164865+00:00 heroku[web.1]: Process exited with status 1
2019-12-13T03:03:24.145385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=ca564a1c-156c-484a-9354-ce243b3b1ed5 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:03:24.586560+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=bb81ead2-cd04-462f-9ab9-64b84d9238bb fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:08:40.000000+00:00 app[api]: Build started by user deon.choi#gmail.com
2019-12-13T03:08:55.468949+00:00 app[api]: Deploy 67508aba by user deon.choi#gmail.com
2019-12-13T03:08:55.468949+00:00 app[api]: Release v4 created by user deon.choi#gmail.com
2019-12-13T03:08:55.741086+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-13T03:08:56.000000+00:00 app[api]: Build succeeded
2019-12-13T03:08:57.971434+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-13T03:08:59.915432+00:00 app[web.1]:
2019-12-13T03:08:59.915464+00:00 app[web.1]: > backend#1.0.0 start /app
2019-12-13T03:08:59.915467+00:00 app[web.1]: > node server.js
2019-12-13T03:08:59.915470+00:00 app[web.1]:
2019-12-13T03:09:00.319828+00:00 app[web.1]:
2019-12-13T03:09:00.319851+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:541
2019-12-13T03:09:00.319854+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-12-13T03:09:00.319857+00:00 app[web.1]: ^
2019-12-13T03:09:00.322625+00:00 app[web.1]: Error [MongooseError]: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2019-12-13T03:09:00.322629+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:10:11)
2019-12-13T03:09:00.322632+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:541:11)
2019-12-13T03:09:00.322634+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:328:15)
2019-12-13T03:09:00.322636+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2019-12-13T03:09:00.322639+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-13T03:09:00.322641+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-13T03:09:00.322644+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-13T03:09:00.322646+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-13T03:09:00.322648+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
2019-12-13T03:09:00.322651+00:00 app[web.1]: at internal/main/run_main_module.js:17:11 {
2019-12-13T03:09:00.322654+00:00 app[web.1]: message: 'The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.',
2019-12-13T03:09:00.322657+00:00 app[web.1]: name: 'MongooseError'
2019-12-13T03:09:00.322660+00:00 app[web.1]: }
2019-12-13T03:09:00.331200+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-13T03:09:00.331487+00:00 app[web.1]: npm ERR! errno 1
2019-12-13T03:09:00.333012+00:00 app[web.1]: npm ERR! backend#1.0.0 start: `node server.js`
2019-12-13T03:09:00.333312+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-13T03:09:00.333487+00:00 app[web.1]: npm ERR!
2019-12-13T03:09:00.333633+00:00 app[web.1]: npm ERR! Failed at the backend#1.0.0 start script.
2019-12-13T03:09:00.333752+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-13T03:09:00.341621+00:00 app[web.1]:
2019-12-13T03:09:00.341770+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-13T03:09:00.341887+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-13T03_09_00_334Z-debug.log
2019-12-13T03:09:00.424560+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-13T03:09:00.403174+00:00 heroku[web.1]: Process exited with status 1
2019-12-13T03:09:01.483310+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=79b75979-00fa-4994-a5d1-4f73c5841172 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:02.191776+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=93cf4327-3365-4174-a2df-7545952b00a6 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:03.076316+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=a2492372-c679-4144-acd1-7956692ad1e0 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:03.469741+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=d14e6638-96d5-4f19-8701-03ab766969fc fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:47.050280+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shrinkurlapp.herokuapp.com request_id=287c82b4-b3a6-42cc-81c5-ed97f310f7d3 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
2019-12-13T03:09:47.349496+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shrinkurlapp.herokuapp.com request_id=b1ced555-16fd-4255-92be-486d0917aff1 fwd="98.210.22.60" dyno= connect= service= status=503 bytes= protocol=https
I thought the issue was with my mongoose.connect() statement but it seems as if that is not the case.
Here is my server.js express file:
const express = require('express');
const cors = require('cors');
const mongoose = require('mongoose');
const cookieParser = require('cookie-parser');
const path = require('path');
require('dotenv').config();
const app = express();
const port = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
app.use(cookieParser());
const dbURI = process.env.DB_CONNECTION;
mongoose.connect(dbURI, {useNewUrlParser: true, useUnifiedTopology: true});
const connection = mongoose.connection;
connection.once('open', () => {
console.log('MongoDB database connection established successfully');
});
const urlsRouter = require('./routes/urls');
const redirectRouter = require('./routes/index');
const authRoute = require('./routes/auth');
app.use('/api/urls', urlsRouter);
app.use('/api/user', authRoute);
app.use('/api', redirectRouter);
app.use(express.static(path.join(__dirname, 'build')));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'build', 'index.html'));
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`)
});
refer the following to set environment variable to be used:
https://devcenter.heroku.com/articles/config-vars
The env variable that requires to be set is : DB_CONNECTION

Heroku application not loading on few browsers

I deployed a Node.js application on Heroku through CLI. The steps I followed are
Git add .
Git commit -am "message"
git heroku push master
heroku open
I didnt get any error and when I run heroku open, the app is running on my browser. The problem is that when I try to run it using different browsers or through mobile browser its not loading.
This is the url : https://smit21.herokuapp.com/
Heroku logs:
2018-09-22T10:45:10.910105+00:00 heroku[web.1]: State changed from starting to up
2018-09-22T10:45:11.024839+00:00 app[web.1]: mongo is successfully Connected
2018-09-22T10:45:11.730224+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=3da0a9c2-6a20-4f07-9832-03384d0030f0 fwd="130.217.199.41" dyno=web.1 connect=1ms service=15ms status=304 bytes=149 protocol=https
2018-09-22T10:45:22.179407+00:00 heroku[router]: at=info method=GET path="/style.css" host=smit21.herokuapp.com request_id=9e8e12f2-3a10-4737-ad59-5a80fc543e15 fwd="130.217.199.41" dyno=web.1 connect=0ms service=22ms status=200 bytes=1671 protocol=https
2018-09-22T10:45:22.467080+00:00 heroku[router]: at=info method=GET path="/service-worker.js" host=smit21.herokuapp.com request_id=23c73ab0-c7dc-4795-8071-96f227c25de7 fwd="130.217.199.41" dyno=web.1 connect=0ms service=6ms status=200 bytes=1671 protocol=https
2018-09-22T10:46:42.380939+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=3d720461-a453-4406-ab50-e619e4a1ca17 fwd="130.217.199.41" dyno=web.1 connect=1ms service=4ms status=304 bytes=149 protocol=https
2018-09-22T11:20:22.770459+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=12c5acba-bf57-4fff-b105-872666b2cedb fwd="130.217.252.116" dyno=web.1 connect=1ms service=3ms status=200 bytes=205 protocol=http
2018-09-22T11:20:23.078071+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=smit21.herokuapp.com request_id=b4012891-eeb7-4475-93e0-42b95464b751 fwd="130.217.252.116" dyno=web.1 connect=1ms service=11ms status=200 bytes=1671 protocol=http
2018-09-22T11:21:23.714105+00:00 heroku[web.1]: Idling
2018-09-22T11:21:23.714612+00:00 heroku[web.1]: State changed from up to down
2018-09-22T11:21:24.902989+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-22T11:21:25.009609+00:00 heroku[web.1]: Process exited with status 143
2018-09-22T12:19:21.492774+00:00 heroku[web.1]: Unidling
2018-09-22T12:19:21.493013+00:00 heroku[web.1]: State changed from down to starting
2018-09-22T12:19:31.538143+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-22T12:19:34.484663+00:00 app[web.1]:
2018-09-22T12:19:34.484689+00:00 app[web.1]: > connectify#1.0.0 start /app
2018-09-22T12:19:34.484691+00:00 app[web.1]: > node server.js
2018-09-22T12:19:34.484692+00:00 app[web.1]:
2018-09-22T12:19:36.922548+00:00 heroku[web.1]: State changed from starting to up
2018-09-22T12:19:36.806116+00:00 app[web.1]: (node:21) 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.
2018-09-22T12:19:36.808856+00:00 app[web.1]: server running on ${port}
2018-09-22T12:19:37.512586+00:00 app[web.1]: mongo is successfully Connected
2018-09-22T12:19:37.644321+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=ee35c390-7a01-47cd-a735-fbc0a09dfa17 fwd="67.81.155.224" dyno=web.1 connect=1ms service=33ms status=200 bytes=205 protocol=https
2018-09-22T12:19:38.625988+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=smit21.herokuapp.com request_id=59431a7d-0435-482e-be56-bc40ec0d7040 fwd="67.81.155.224" dyno=web.1 connect=1ms service=18ms status=200 bytes=1671 protocol=https
2018-09-22T12:37:21.169018+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=a7f0cd4d-564d-4b2c-b2f5-c6b447cf113d fwd="42.113.162.220" dyno=web.1 connect=0ms service=8ms status=200 bytes=205 protocol=https
2018-09-22T12:37:21.688111+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=smit21.herokuapp.com request_id=e942379d-0505-4c52-8a79-06774538178a fwd="42.113.162.220" dyno=web.1 connect=0ms service=6ms status=200 bytes=1671 protocol=https
2018-09-22T13:12:41.189319+00:00 heroku[web.1]: Idling
2018-09-22T13:12:41.189770+00:00 heroku[web.1]: State changed from up to down
2018-09-22T13:12:42.083740+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-22T13:12:42.244254+00:00 heroku[web.1]: Process exited with status 143
2018-09-22T13:40:40.011490+00:00 heroku[web.1]: Unidling
2018-09-22T13:40:40.011737+00:00 heroku[web.1]: State changed from down to starting
2018-09-22T13:40:49.782284+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-22T13:40:52.738181+00:00 app[web.1]:
2018-09-22T13:40:52.738215+00:00 app[web.1]: > connectify#1.0.0 start /app
2018-09-22T13:40:52.738216+00:00 app[web.1]: > node server.js
2018-09-22T13:40:52.738217+00:00 app[web.1]:
2018-09-22T13:40:56.345158+00:00 app[web.1]: (node:21) 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.
2018-09-22T13:40:56.347202+00:00 app[web.1]: server running on ${port}
2018-09-22T13:40:56.727105+00:00 heroku[web.1]: State changed from starting to up
2018-09-22T13:40:57.065561+00:00 app[web.1]: mongo is successfully Connected
2018-09-22T13:40:58.175235+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=11684ba9-34ff-4e3c-b80d-bb4738826fba fwd="185.20.6.43" dyno=web.1 connect=1ms service=27ms status=200 bytes=205 protocol=https
2018-09-22T14:13:38.051816+00:00 heroku[web.1]: Idling
2018-09-22T14:13:38.052343+00:00 heroku[web.1]: State changed from up to down
2018-09-22T14:13:39.140424+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-22T14:13:39.513941+00:00 heroku[web.1]: Process exited with status 143
2018-09-22T17:49:30.699850+00:00 heroku[web.1]: Unidling
2018-09-22T17:49:30.700095+00:00 heroku[web.1]: State changed from down to starting
2018-09-22T17:49:30.712308+00:00 heroku[web.1]: Unidling
2018-09-22T17:49:30.712582+00:00 heroku[web.1]: State changed from down to starting
2018-09-22T17:49:40.987766+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-22T17:49:43.759282+00:00 app[web.1]:
2018-09-22T17:49:43.759314+00:00 app[web.1]: > connectify#1.0.0 start /app
2018-09-22T17:49:43.759315+00:00 app[web.1]: > node server.js
2018-09-22T17:49:43.759316+00:00 app[web.1]:
2018-09-22T17:49:46.124612+00:00 app[web.1]: (node:21) 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.
2018-09-22T17:49:46.126979+00:00 app[web.1]: server running on ${port}
2018-09-22T17:49:46.522505+00:00 heroku[web.1]: State changed from starting to up
2018-09-22T17:49:46.644735+00:00 app[web.1]: mongo is successfully Connected
2018-09-22T17:49:48.917314+00:00 heroku[router]: at=info method=GET path="/robots.txt" host=smit21.herokuapp.com request_id=903a4039-97bc-4828-812b-f1acc2cdc513 fwd="37.170.118.162" dyno=web.1 connect=0ms service=68ms status=200 bytes=1671 protocol=https
2018-09-22T17:49:48.876338+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=9e23b162-b656-447f-a89e-ae5130b3b8bc fwd="37.170.118.162" dyno=web.1 connect=1ms service=31ms status=200 bytes=205 protocol=https
2018-09-22T17:49:51.070701+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=smit21.herokuapp.com request_id=3aaa52db-476e-411f-b6aa-8158dff352cd fwd="37.170.118.162" dyno=web.1 connect=0ms service=8ms status=200 bytes=1671 protocol=https
2018-09-22T18:27:03.807779+00:00 heroku[web.1]: Idling
2018-09-22T18:27:03.808281+00:00 heroku[web.1]: State changed from up to down
2018-09-22T18:27:04.892238+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-22T18:27:05.038741+00:00 heroku[web.1]: Process exited with status 143
2018-09-22T22:01:22.982040+00:00 heroku[web.1]: Unidling
2018-09-22T22:01:22.982330+00:00 heroku[web.1]: State changed from down to starting
2018-09-22T22:01:33.438308+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-22T22:01:36.517339+00:00 app[web.1]:
2018-09-22T22:01:36.517389+00:00 app[web.1]: > connectify#1.0.0 start /app
2018-09-22T22:01:36.517391+00:00 app[web.1]: > node server.js
2018-09-22T22:01:36.517392+00:00 app[web.1]:
2018-09-22T22:01:39.339911+00:00 app[web.1]: (node:21) 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.
2018-09-22T22:01:39.348746+00:00 app[web.1]: server running on ${port}
2018-09-22T22:01:39.761169+00:00 heroku[web.1]: State changed from starting to up
2018-09-22T22:01:39.933342+00:00 app[web.1]: mongo is successfully Connected
2018-09-22T22:01:41.162080+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=d176ed5c-f629-4964-8e78-2bb73b521af3 fwd="185.20.6.141" dyno=web.1 connect=0ms service=26ms status=200 bytes=205 protocol=https
2018-09-22T22:36:02.306389+00:00 heroku[web.1]: Idling
2018-09-22T22:36:02.306919+00:00 heroku[web.1]: State changed from up to down
2018-09-22T22:36:03.163997+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-22T22:36:03.277923+00:00 heroku[web.1]: Process exited with status 143
2018-09-23T00:13:07.000615+00:00 heroku[web.1]: Unidling
2018-09-23T00:13:07.000863+00:00 heroku[web.1]: State changed from down to starting
2018-09-23T00:13:12.849997+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-23T00:13:14.641841+00:00 app[web.1]:
2018-09-23T00:13:14.641858+00:00 app[web.1]: > connectify#1.0.0 start /app
2018-09-23T00:13:14.641860+00:00 app[web.1]: > node server.js
2018-09-23T00:13:14.641861+00:00 app[web.1]:
2018-09-23T00:13:15.926398+00:00 app[web.1]: (node:21) 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.
2018-09-23T00:13:15.927682+00:00 app[web.1]: server running on ${port}
2018-09-23T00:13:16.612593+00:00 heroku[web.1]: State changed from starting to up
2018-09-23T00:13:16.526867+00:00 app[web.1]: mongo is successfully Connected
2018-09-23T00:13:19.158301+00:00 heroku[router]: at=info method=GET path="/" host=smit21.herokuapp.com request_id=1753b2d3-291f-4cc4-a02d-184ed39337e9 fwd="24.87.72.248" dyno=web.1 connect=0ms service=10ms status=200 bytes=205 protocol=https
2018-09-23T00:13:19.821530+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=smit21.herokuapp.com request_id=a4270213-9ac1-4e68-827f-ea7e9ac365ba fwd="24.87.72.248" dyno=web.1 connect=0ms service=13ms status=200 bytes=1671 protocol=https
2018-09-23T00:49:06.417379+00:00 heroku[web.1]: Idling
2018-09-23T00:49:06.417954+00:00 heroku[web.1]: State changed from up to down
2018-09-23T00:49:07.535197+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-09-23T00:49:07.751341+00:00 heroku[web.1]: Process exited with status 143
Screenshot when trying to run heroku open
server.js
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const passport = require('passport');
const path = require('path');
const users = require('./routes/api/users');
const profile = require('./routes/api/profile');
const posts = require('./routes/api/posts');
const app = express();
// Body parser middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// DB Config
const db = require('./config/keys').mongoURI;
// Connect to MongoDB
mongoose
.connect(db)
.then(() => console.log('MongoDB Connected'))
.catch(err => console.log(err));
// Passport middleware
app.use(passport.initialize());
// Passport Config
require('./config/passport')(passport);
// Use Routes
app.use('/api/users', users);
app.use('/api/profile', profile);
app.use('/api/posts', posts);
// Server static assets if in production
if (process.env.NODE_ENV === 'production') {
// Set static folder
app.use(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Server running on port ${port}`));
package.json
"heroku-postbuild":
"NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --prefix frontend"

Resources