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"
Related
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.
this is my first project in node js and it worked perfect on localhost but when i deployed it on heroku it's not working and shows application error,, i couldn't figure out what is the problem and below is my heroku logs and server.js code.
can someone please help me solve this?
thanks in advance
const express = require('express');
const morgan = require('morgan');
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const jwt = require('jsonwebtoken');
const http = require('http');
const multer = require("multer");
const app = express();
const server = http.createServer(app);
// corsfffffffff
/************************************** Socket IO Related Start ************************************************/
// config dotenv
dotenv.config();
const dbURI = process.env.MONGO_URL || "mongodb+srv://user:cvcvcv00S-#cluster0.jpij0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";
mongoose.connect(dbURI, { useNewUrlParser: true, useUnifiedTopology: true })
.then(result => server.listen(process.env.PORT || 3000) )
.catch(err => console.log(err));
app.set('view engine', 'ejs');
app.use(express.json);
// app.use(express.urlencoded({ extended: true }));
// app.use(morgan("dev"));
app.use((req, res, next) => {
res.locals.path = req.path;
next();
});
const subscribersRouter = require('./routes/subscribers')
app.use('/subscribers', subscribersRouter)
app.get("/", function(req,res){
res.send("welcome to app");
})
heroku logs:
2021-12-09T19:50:00.133986+00:00 app[web.1]:
2021-12-09T19:50:00.134003+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T19:50:00.134003+00:00 app[web.1]: > node app.js
2021-12-09T19:50:00.134003+00:00 app[web.1]:
2021-12-09T19:50:01.187253+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T19:50:32.260199+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=obscure-waters-05043.herokuapp.com request_id=cfbf2688-d4d4-4b7a-adf0-2663a1d7dace fwd="85.108.198.36" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https
2021-12-09T19:50:43.082048+00:00 heroku[web.1]: Restarting
2021-12-09T19:50:43.107251+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T19:50:43.871385+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T19:50:44.069113+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/favicon.ico" host=obscure-waters-05043.herokuapp.com request_id=49445fee-a0d0-4199-9adb-bf4314016e98 fwd="85.108.198.36" dyno=web.1 connect=0ms service=11418ms status=503 bytes=0 protocol=https
2021-12-09T19:50:44.193647+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T19:50:45.155711+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T19:50:46.561346+00:00 app[web.1]:
2021-12-09T19:50:46.561360+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T19:50:46.561361+00:00 app[web.1]: > node app.js
2021-12-09T19:50:46.561361+00:00 app[web.1]:
2021-12-09T19:50:47.295414+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T19:51:51.000000+00:00 app[api]: Build started by user sebaalchalabi#gmail.com
2021-12-09T19:52:08.296910+00:00 app[api]: Deploy 202801b6 by user sebaalchalabi#gmail.com
2021-12-09T19:52:08.296910+00:00 app[api]: Release v44 created by user sebaalchalabi#gmail.com
2021-12-09T19:52:08.590301+00:00 heroku[web.1]: Restarting
2021-12-09T19:52:08.615504+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T19:52:09.000000+00:00 app[api]: Build succeeded
2021-12-09T19:52:09.331866+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T19:52:09.574745+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T19:52:10.680588+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T19:52:11.875404+00:00 app[web.1]:
2021-12-09T19:52:11.875420+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T19:52:11.875420+00:00 app[web.1]: > node app.js
2021-12-09T19:52:11.875420+00:00 app[web.1]:
2021-12-09T19:52:12.491955+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T19:53:21.013488+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=obscure-waters-05043.herokuapp.com request_id=3d66d37c-eec6-44d2-8792-a7ddff579766 fwd="85.108.198.36" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https
2021-12-09T19:53:41.188552+00:00 heroku[web.1]: Restarting
2021-12-09T19:53:41.191420+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T19:53:41.978236+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T19:53:42.180105+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/favicon.ico" host=obscure-waters-05043.herokuapp.com request_id=98bb6ae6-b3ec-4206-95a4-6279e7aff78b fwd="85.108.198.36" dyno=web.1 connect=0ms service=20953ms status=503 bytes=0 protocol=https
2021-12-09T19:53:42.314257+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T19:53:43.672529+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T19:53:45.699311+00:00 app[web.1]:
2021-12-09T19:53:45.699323+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T19:53:45.699324+00:00 app[web.1]: > node app.js
2021-12-09T19:53:45.699324+00:00 app[web.1]:
2021-12-09T19:53:47.034852+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T19:57:01.713660+00:00 heroku[web.1]: Restarting
2021-12-09T19:57:01.847677+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T19:57:02.852486+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T19:57:03.172988+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T19:57:04.132727+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T19:57:05.215604+00:00 app[web.1]:
2021-12-09T19:57:05.215618+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T19:57:05.215618+00:00 app[web.1]: > node app.js
2021-12-09T19:57:05.215618+00:00 app[web.1]:
2021-12-09T19:57:05.821299+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T19:57:15.000000+00:00 app[api]: Build started by user sebaalchalabi#gmail.com
2021-12-09T19:57:30.843649+00:00 app[api]: Release v45 created by user sebaalchalabi#gmail.com
2021-12-09T19:57:30.843649+00:00 app[api]: Deploy 338ae6f5 by user sebaalchalabi#gmail.com
2021-12-09T19:57:31.000000+00:00 app[api]: Build succeeded
2021-12-09T19:57:31.085978+00:00 heroku[web.1]: Restarting
2021-12-09T19:57:31.201283+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T19:57:31.880715+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T19:57:32.065101+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T19:57:33.428958+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T19:57:34.677151+00:00 app[web.1]:
2021-12-09T19:57:34.677180+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T19:57:34.677181+00:00 app[web.1]: > node app.js
2021-12-09T19:57:34.677181+00:00 app[web.1]:
2021-12-09T19:57:35.761777+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T19:58:08.215698+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=obscure-waters-05043.herokuapp.com request_id=51f7029d-58a6-445a-a111-a77bccfa90c0 fwd="85.108.198.36" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2021-12-09T19:58:38.614677+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=obscure-waters-05043.herokuapp.com request_id=56500d70-9535-4cdf-8665-2cfe463b908d fwd="85.108.198.36" dyno=web.1 connect=0ms service=30002ms status=503 bytes=0 protocol=https
2021-12-09T20:05:25.879914+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=obscure-waters-05043.herokuapp.com request_id=e7ff010a-b9b7-49e8-bae6-b72eb0794c0e fwd="34.204.52.120" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=http
2021-12-09T20:07:18.000000+00:00 app[api]: Build started by user sebaalchalabi#gmail.com
2021-12-09T20:07:34.550502+00:00 app[api]: Release v46 created by user sebaalchalabi#gmail.com
2021-12-09T20:07:34.550502+00:00 app[api]: Deploy 274eee09 by user sebaalchalabi#gmail.com
2021-12-09T20:07:35.000000+00:00 app[api]: Build succeeded
2021-12-09T20:07:38.124510+00:00 heroku[web.1]: Restarting
2021-12-09T20:07:38.227065+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T20:07:39.027871+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T20:07:39.245964+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T20:07:40.890971+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T20:07:42.140238+00:00 app[web.1]:
2021-12-09T20:07:42.140265+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T20:07:42.140265+00:00 app[web.1]: > node app.js
2021-12-09T20:07:42.140266+00:00 app[web.1]:
2021-12-09T20:07:43.221265+00:00 heroku[web.1]: State changed from starting to up
2021-12-09T20:08:14.814637+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=obscure-waters-05043.herokuapp.com request_id=afc72089-87b7-4d01-a2dd-a0efddfc3d62 fwd="85.108.198.36" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2021-12-09T20:08:45.157453+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/favicon.ico" host=obscure-waters-05043.herokuapp.com request_id=b38528cf-d42d-4184-b52b-6808444e99bd fwd="85.108.198.36" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2021-12-09T20:13:59.000000+00:00 app[api]: Build started by user sebaalchalabi#gmail.com
2021-12-09T20:14:15.262368+00:00 app[api]: Deploy fe24fd44 by user sebaalchalabi#gmail.com
2021-12-09T20:14:15.262368+00:00 app[api]: Release v47 created by user sebaalchalabi#gmail.com
2021-12-09T20:14:15.498236+00:00 heroku[web.1]: Restarting
2021-12-09T20:14:15.523576+00:00 heroku[web.1]: State changed from up to starting
2021-12-09T20:14:16.000000+00:00 app[api]: Build succeeded
2021-12-09T20:14:16.770111+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-12-09T20:14:17.043608+00:00 heroku[web.1]: Process exited with status 143
2021-12-09T20:14:17.959793+00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-09T20:14:19.191029+00:00 app[web.1]:
2021-12-09T20:14:19.191041+00:00 app[web.1]: > api-master-nodejs#1.0.0 start /app
2021-12-09T20:14:19.191041+00:00 app[web.1]: > node app.js
2021-12-09T20:14:19.191042+00:00 app[web.1]:
2021-12-09T20:14:19.891841+00:00 heroku[web.1]: State changed from starting to up
Did you install all the modules using npm install --save <module>? If you don't include the --save option, then the module won't be written to your package.json file which Heroku uses to automatically download the dependencies.
I've created a single page app using the PERN stack and have successfully deployed it to Heroku. Now I am trying to switch to https on the backend, and have creaed a selfsigned.crt file and a selfsigned.key file, but I can't figure out this current error.
Here's my db.js
let connectionString = {
connectionString:
process.env.DATABASE_URL,
ssl: true,
};
const pool = new Pool(connectionString);
module.exports = pool;
Here's my server.js
const express = require("express");
const app = express();
const fs = require("fs");
const https = require("https");
const httpsPort = process.env.PORT || 8443;
const privateKey = fs.readFileSync("./sslCertification/selfsigned.key", "utf8");
const certificate = fs.readFileSync("./sslCertification/selfsigned.crt", "utf8");
const credentials = { key: privateKey, cert: certificate };
const priorityStatus = require("./routes/priorityStatus");
const accounts = require("./routes/accounts");
const projects = require("./routes/projects");
const bugs = require("./routes/bugs");
const comments = require("./routes/comments");
app.use(express.json());
app.all('*', function(req, res, next) {
if (req.headers['x-forwarded-proto'] != 'https')
res.redirect('https://' + req.headers.host + req.url)
else
next()
});
// Needed since single page application
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'));
}
app.get('*', (request, response) => {
response.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
app.use("/api/priority-status", priorityStatus);
app.use("/api/account", accounts);
app.use("/api/project", projects);
app.use("/api/bug", bugs);
app.use("/api/comment", comments);
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(httpsPort);
// Was using this before switching to https
/* app.listen(process.env.PORT || 5000, () => {
console.log("Server has started on port 5000");
}); */
Here's what I get in my Heroku log --tail.
2020-12-16T23:45:25.843470+00:00 app[web.1]: [1] > server#1.0.0 client /app
2020-12-16T23:45:25.843471+00:00 app[web.1]: [1] > npm start --prefix ./client
2020-12-16T23:45:25.843472+00:00 app[web.1]: [1]
2020-12-16T23:45:26.287947+00:00 app[web.1]: [0]
2020-12-16T23:45:26.287959+00:00 app[web.1]: [0] > server#1.0.0 server /app
2020-12-16T23:45:26.287960+00:00 app[web.1]: [0] > npm start server.js
2020-12-16T23:45:26.287960+00:00 app[web.1]: [0]
2020-12-16T23:45:27.261503+00:00 app[web.1]: [1]
2020-12-16T23:45:27.261511+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2020-12-16T23:45:27.261512+00:00 app[web.1]: [1] > react-scripts start
2020-12-16T23:45:27.261512+00:00 app[web.1]: [1]
2020-12-16T23:45:27.287963+00:00 app[web.1]: [0]
2020-12-16T23:45:27.287965+00:00 app[web.1]: [0] > server#1.0.0 start /app
2020-12-16T23:45:27.287966+00:00 app[web.1]: [0] > node server.js "server.js"
2020-12-16T23:45:27.287966+00:00 app[web.1]: [0]
2020-12-16T23:45:29.329961+00:00 app[web.1]: [0] Server has started on port 5000
2020-12-16T23:45:29.377253+00:00 heroku[web.1]: State changed from starting to up
2020-12-16T23:45:31.082924+00:00 heroku[router]: at=info method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=d77f6dfd-b5e2-4f8c-b5ec-6c8ca90063dd fwd="107.181.184.23" dyno=web.1 connect=1ms service=62ms status=200 bytes=2573 protocol=https
2020-12-16T23:45:31.327977+00:00 heroku[router]: at=info method=GET path="/static/js/main.627d6695.chunk.js" host=my-bug-tracker.herokuapp.com request_id=3e09e810-ba9b-4ffc-80ec-1452b4dc3fde fwd="107.181.184.23" dyno=web.1 connect=0ms service=8ms status=200 bytes=118886 protocol=https
2020-12-16T23:45:31.580398+00:00 heroku[router]: at=info method=GET path="/static/css/2.e6f51e71.chunk.css" host=my-bug-tracker.herokuapp.com request_id=fd127936-041d-4621-8417-4ab61d3be700 fwd="107.181.184.23" dyno=web.1 connect=1ms service=5ms status=200 bytes=30948 protocol=https
2020-12-16T23:45:31.766225+00:00 heroku[router]: at=info method=GET path="/static/css/main.baebc1a0.chunk.css" host=my-bug-tracker.herokuapp.com request_id=0cbed062-cc5a-4b0b-a5b5-9e0c6c126411 fwd="107.181.184.23" dyno=web.1 connect=0ms service=33ms status=200 bytes=51828 protocol=https
2020-12-16T23:45:31.800991+00:00 heroku[router]: at=info method=GET path="/static/js/2.86007984.chunk.js" host=my-bug-tracker.herokuapp.com request_id=4cb8b8f0-7a9f-4d19-b5e7-886956ff367b fwd="107.181.184.23" dyno=web.1 connect=0ms service=17ms status=200 bytes=256970 protocol=https
2020-12-16T23:45:32.395277+00:00 heroku[router]: at=info method=GET path="/static/media/BlueBackground_1920.f1fd53eb.jpg" host=my-bug-tracker.herokuapp.com request_id=fec9221a-2535-4a31-aa23-faae29fd9278 fwd="107.181.184.23" dyno=web.1 connect=0ms service=79ms status=200 bytes=193680 protocol=https
2020-12-16T23:45:32.435799+00:00 heroku[router]: at=info method=GET path="/bug-icon-white-background-thick.ico" host=my-bug-tracker.herokuapp.com request_id=2c3fcb80-9d59-4e2d-82cb-e40e069572fc fwd="107.181.184.23" dyno=web.1 connect=0ms service=11ms status=200 bytes=14451 protocol=https
2020-12-16T23:45:34.651092+00:00 app[web.1]: [1] Something is already running on port 32518.
2020-12-16T23:45:34.713739+00:00 app[web.1]: [1] npm run client exited with code 0
2020-12-16T23:45:38.231748+00:00 heroku[router]: at=info method=POST path="/api/account/login" host=my-bug-tracker.herokuapp.com request_id=a98b5798-90c0-43d5-951e-9eedb3caf308 fwd="107.181.184.23" dyno=web.1 connect=0ms service=365ms status=200 bytes=18030 protocol=https
2020-12-16T23:45:38.468324+00:00 heroku[router]: at=info method=GET path="/static/media/sort-arrows-both-empty.4823f7dd.svg" host=my-bug-tracker.herokuapp.com request_id=5ac2ebe3-eade-4929-ac13-a9c130ee49ba fwd="107.181.184.23" dyno=web.1 connect=0ms service=9ms status=200 bytes=2668 protocol=https
2020-12-16T23:45:38.469210+00:00 heroku[router]: at=info method=GET path="/static/media/sort-arrows-top-filled.d4ef80d2.svg" host=my-bug-tracker.herokuapp.com request_id=86e2dc2d-3cbd-49f3-9bff-d0318bfd88e6 fwd="107.181.184.23" dyno=web.1 connect=0ms service=10ms status=200 bytes=2700 protocol=https
2020-12-16T23:45:38.508359+00:00 heroku[router]: at=info method=GET path="/static/media/fontawesome-webfont.af7ae505.woff2" host=my-bug-tracker.herokuapp.com request_id=1c3618aa-6c2d-4849-9742-40b7cf76c25e fwd="107.181.184.23" dyno=web.1 connect=1ms service=10ms status=200 bytes=77438 protocol=https
2020-12-16T23:46:24.944613+00:00 heroku[router]: at=info method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=0825b13a-7917-43d4-bcd9-c0c96df2dc06 fwd="107.181.184.23" dyno=web.1 connect=0ms service=3ms status=304 bytes=237 protocol=https
2020-12-16T23:46:25.177238+00:00 heroku[router]: at=info method=GET path="/static/css/2.e6f51e71.chunk.css" host=my-bug-tracker.herokuapp.com request_id=24c6a746-e906-49db-83ce-ccbe39a274ab fwd="107.181.184.23" dyno=web.1 connect=0ms service=4ms status=200 bytes=30948 protocol=https
2020-12-16T23:46:25.179901+00:00 heroku[router]: at=info method=GET path="/static/css/main.baebc1a0.chunk.css" host=my-bug-tracker.herokuapp.com request_id=d88baeaf-45ac-44fa-8e36-8b4a513c0e9f fwd="107.181.184.23" dyno=web.1 connect=1ms service=7ms status=200 bytes=51828 protocol=https
2020-12-16T23:46:25.184930+00:00 heroku[router]: at=info method=GET path="/static/js/2.86007984.chunk.js" host=my-bug-tracker.herokuapp.com request_id=23923f21-2b35-4eae-9ec4-a5bb511f7fc9 fwd="107.181.184.23" dyno=web.1 connect=0ms service=2ms status=304 bytes=239 protocol=https
2020-12-16T23:46:25.674846+00:00 heroku[router]: at=info method=GET path="/static/js/main.627d6695.chunk.js" host=my-bug-tracker.herokuapp.com request_id=92de810a-64b1-4723-ade4-f3af20f16914 fwd="107.181.184.23" dyno=web.1 connect=0ms service=2ms status=304 bytes=239 protocol=https
2020-12-16T23:46:25.895205+00:00 heroku[router]: at=info method=GET path="/static/media/BlueBackground_1920.f1fd53eb.jpg" host=my-bug-tracker.herokuapp.com request_id=8120bdf0-664b-42a5-9466-47ff254605e0 fwd="107.181.184.23" dyno=web.1 connect=0ms service=14ms status=200 bytes=193680 protocol=https
2020-12-16T23:46:26.005483+00:00 heroku[router]: at=info method=GET path="/bug-icon-white-background-thick.ico" host=my-bug-tracker.herokuapp.com request_id=6d37a9df-6bad-44c6-bf4c-4871036094b0 fwd="107.181.184.23" dyno=web.1 connect=1ms service=5ms status=200 bytes=14451 protocol=https
2020-12-17T00:17:57.035580+00:00 heroku[web.1]: Idling
2020-12-17T00:17:57.038063+00:00 heroku[web.1]: State changed from up to down
2020-12-17T00:17:58.600226+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-12-17T00:17:58.725162+00:00 heroku[web.1]: Process exited with status 143
2020-12-19T00:16:45.000000+00:00 app[api]: Build started by user myemail#outlook.com
2020-12-19T00:18:36.760218+00:00 app[api]: Release v32 created by user myemail#outlook.com
2020-12-19T00:18:36.760218+00:00 app[api]: Deploy a56a8d74 by user myemail#outlook.com
2020-12-19T00:18:37.085799+00:00 heroku[web.1]: State changed from down to starting
2020-12-19T00:18:38.000000+00:00 app[api]: Build succeeded
2020-12-19T00:18:46.854143+00:00 heroku[web.1]: Starting process with command `npm run dev`
2020-12-19T00:18:49.111701+00:00 app[web.1]:
2020-12-19T00:18:49.111720+00:00 app[web.1]: > server#1.0.0 dev /app
2020-12-19T00:18:49.111721+00:00 app[web.1]: > concurrently "npm run server" "npm run client"
2020-12-19T00:18:49.111721+00:00 app[web.1]:
2020-12-19T00:18:50.371711+00:00 app[web.1]: [0]
2020-12-19T00:18:50.371740+00:00 app[web.1]: [0] > server#1.0.0 server /app
2020-12-19T00:18:50.371741+00:00 app[web.1]: [0] > npm start server.js
2020-12-19T00:18:50.371741+00:00 app[web.1]: [0]
2020-12-19T00:18:50.685530+00:00 app[web.1]: [1]
2020-12-19T00:18:50.685542+00:00 app[web.1]: [1] > server#1.0.0 client /app
2020-12-19T00:18:50.685542+00:00 app[web.1]: [1] > npm start --prefix ./client
2020-12-19T00:18:50.685543+00:00 app[web.1]: [1]
2020-12-19T00:18:50.962753+00:00 app[web.1]: [0]
2020-12-19T00:18:50.962763+00:00 app[web.1]: [0] > server#1.0.0 start /app
2020-12-19T00:18:50.962764+00:00 app[web.1]: [0] > node server.js "server.js"
2020-12-19T00:18:50.962764+00:00 app[web.1]: [0]
2020-12-19T00:18:51.591232+00:00 heroku[web.1]: State changed from starting to up
2020-12-19T00:18:52.237451+00:00 app[web.1]: [1]
2020-12-19T00:18:52.237462+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2020-12-19T00:18:52.237463+00:00 app[web.1]: [1] > react-scripts start
2020-12-19T00:18:52.237464+00:00 app[web.1]: [1]
2020-12-19T00:18:54.475128+00:00 app[web.1]: [1] Something is already running on port 36160.
2020-12-19T00:18:54.500055+00:00 app[web.1]: [1] npm run client exited with code 0
2020-12-19T00:21:30.162248+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=d2dde696-e905-4999-b060-8f55e67638f8 fwd="73.133.94.85" dyno=web.1 connect=1ms service=8ms status=503 bytes=0 protocol=https
2020-12-19T00:23:04.490925+00:00 heroku[web.1]: Restarting
2020-12-19T00:23:04.507527+00:00 heroku[web.1]: State changed from up to starting
2020-12-19T00:23:05.356455+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-12-19T00:23:05.438828+00:00 heroku[web.1]: Process exited with status 143
2020-12-19T00:23:17.170024+00:00 heroku[web.1]: Starting process with command `npm run dev`
2020-12-19T00:23:20.333801+00:00 app[web.1]:
2020-12-19T00:23:20.333826+00:00 app[web.1]: > server#1.0.0 dev /app
2020-12-19T00:23:20.333827+00:00 app[web.1]: > concurrently "npm run server" "npm run client"
2020-12-19T00:23:20.333827+00:00 app[web.1]:
2020-12-19T00:23:21.436851+00:00 app[web.1]: [0]
2020-12-19T00:23:21.436873+00:00 app[web.1]: [0] > server#1.0.0 server /app
2020-12-19T00:23:21.436873+00:00 app[web.1]: [0] > npm start server.js
2020-12-19T00:23:21.436874+00:00 app[web.1]: [0]
2020-12-19T00:23:21.498752+00:00 app[web.1]: [1]
2020-12-19T00:23:21.498754+00:00 app[web.1]: [1] > server#1.0.0 client /app
2020-12-19T00:23:21.498754+00:00 app[web.1]: [1] > npm start --prefix ./client
2020-12-19T00:23:21.498755+00:00 app[web.1]: [1]
2020-12-19T00:23:22.064333+00:00 app[web.1]: [1]
2020-12-19T00:23:22.064355+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2020-12-19T00:23:22.064356+00:00 app[web.1]: [1] > react-scripts start
2020-12-19T00:23:22.064356+00:00 app[web.1]: [1]
2020-12-19T00:23:22.116724+00:00 app[web.1]: [0]
2020-12-19T00:23:22.116727+00:00 app[web.1]: [0] > server#1.0.0 start /app
2020-12-19T00:23:22.116729+00:00 app[web.1]: [0] > node server.js "server.js"
2020-12-19T00:23:22.116729+00:00 app[web.1]: [0]
2020-12-19T00:23:23.302719+00:00 heroku[web.1]: State changed from starting to up
2020-12-19T00:23:24.037351+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=my-bug-tracker.herokuapp.com request_id=6c715c5a-4f70-4e16-8a4c-307adb441f0a fwd="73.133.94.85" dyno=web.1 connect=1ms service=5ms status=503 bytes=0 protocol=https
2020-12-19T00:23:24.579638+00:00 app[web.1]: [1] Something is already running on port 9268.
2020-12-19T00:23:24.631826+00:00 app[web.1]: [1] npm run client exited with code 0
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;
I created an React app (using CRA) with Nodejs backend. Now I tried hosting it. (I've hosted few apps with same stack but didn't faced any issues).
I'm starting both Nodejs and React app using concurrently module with npm run dev.
But this time I'm getting an error and I can't figure out why.
This is what I get when I go the link.
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.
index.js
const express = require('express');
const routes = require('./routes');
const app = express();
const port = 5000 || process.env.PORT;
routes(app);
if(process.env.NODE_ENV === 'production'){
app.use(express.static('client/build'));
const path = require('path');
app.get("*", (req,res) => {
res.sendFile(path.resolve(__dirname,'client','build','index.html'));
})
}
app.listen(port, () => console.log(`Server is running on port ${port}`));
package.json
{
"name": "check-market",
"version": "1.0.0",
"description": "This is a react-nodejs based crypto market checking app",
"main": "index.js",
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "abcd",
"license": "ISC",
"dependencies": {
"concurrently": "^3.5.1",
"cryptocoins-icons": "^2.7.0",
"express": "^4.16.2",
"node-fetch": "^2.0.0",
"nodemon": "^1.14.12"
}
}
heroku logs
2018-04-05T13:41:49.283535+00:00 app[web.1]: [1]2018-04-05T13:41:49.560174+00:00 app[web.1]: [0] Server is running on port 5000
2018-04-05T13:41:51.049613+00:00 app[web.1]: [1] Starting the development server...
2018-04-05T13:41:51.049625+00:00 app[web.1]: [1]
2018-04-05T13:41:51.202463+00:00 heroku[web.1]: State changed from starting to up
2018-04-05T13:42:00.969286+00:00 app[web.1]: [1] Compiled with warnings.
2018-04-05T13:42:00.969303+00:00 app[web.1]: [1]
2018-04-05T13:42:00.969584+00:00 app[web.1]: [1] ./src/components/currency_main.js
2018-04-05T13:42:00.969587+00:00 app[web.1]: [1] Line 49: Expected to return a value in arrow function array-callback-return
2018-04-05T13:42:00.969588+00:00 app[web.1]: [1]
2018-04-05T13:42:00.969590+00:00 app[web.1]: [1] Search for the keywords to learn more about each warning.
2018-04-05T13:42:00.969593+00:00 app[web.1]: [1] To ignore, add // eslint-disable-next-line to the line before.
2018-04-05T13:42:00.969594+00:00 app[web.1]: [1]2018-04-05T13:42:17.377067+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=fa334992-ebb7-4a38-8c2d-e5c09849dcef fwd="112.134.75.196" dyno=web.1 connect=1ms service=13ms status=200 bytes=219 protocol=https
2018-04-05T13:42:18.397503+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=e716c9cb-e910-4f98-8346-4195c6d623ca fwd="112.134.75.196" dyno=web.1 connect=0ms service=7ms status=200 bytes=219 protocol=https
2018-04-05T13:44:47.000000+00:00 app[api]: Build started by user thidasaone#gmail.com
2018-04-05T13:44:47.000000+00:00 app[api]: Build succeeded
2018-04-05T13:46:08.491686+00:00 app[api]: Deploy 0ae9d4f3 by user thidasaone#gmail.com2018-04-05T13:46:08.491686+00:00 app[api]: Release v8 created by user thidasaone#gmail.com2018-04-05T13:46:10.417551+00:00 heroku[web.1]: Restarting
2018-04-05T13:46:10.418403+00:00 heroku[web.1]: State changed from up to starting2018-04-05T13:46:12.169322+00:00 heroku[web.1]: Stopping all processes with SIGTERM2018-04-05T13:46:12.258942+00:00 heroku[web.1]: Process exited with status 143
2018-04-05T13:46:17.859328+00:00 heroku[web.1]: Starting process with command `npm run dev`2018-04-05T13:46:20.219087+00:00 app[web.1]:2018-04-05T13:46:20.219128+00:00 app[web.1]: > check-market#1.0.0 dev /app
2018-04-05T13:46:20.219130+00:00 app[web.1]: > concurrently "npm run server" "npm run client"2018-04-05T13:46:20.219132+00:00 app[web.1]:2018-04-05T13:46:20.817238+00:00 app[web.1]: [0]
2018-04-05T13:46:20.817262+00:00 app[web.1]: [0] > check-market#1.0.0 server /app
2018-04-05T13:46:20.817265+00:00 app[web.1]: [0] > nodemon index.js
2018-04-05T13:46:20.817267+00:00 app[web.1]: [0]
2018-04-05T13:46:20.865621+00:00 app[web.1]: [1]
2018-04-05T13:46:20.865626+00:00 app[web.1]: [1] > check-market#1.0.0 client /app
2018-04-05T13:46:20.865635+00:00 app[web.1]: [1] > npm run start --prefix client
2018-04-05T13:46:20.865636+00:00 app[web.1]: [1]
2018-04-05T13:46:21.154092+00:00 app[web.1]: [0] [nodemon] 1.14.12
2018-04-05T13:46:21.155353+00:00 app[web.1]: [0] [nodemon] to restart at any time, enter `rs`
2018-04-05T13:46:21.155695+00:00 app[web.1]: [0] [nodemon] watching: *.*
2018-04-05T13:46:21.156422+00:00 app[web.1]: [0] [nodemon] starting `node index.js`
2018-04-05T13:46:21.225033+00:00 app[web.1]: [1]
2018-04-05T13:46:21.225037+00:00 app[web.1]: [1] > client#0.1.0 start /app/client
2018-04-05T13:46:21.225039+00:00 app[web.1]: [1] > react-scripts start
2018-04-05T13:46:21.225041+00:00 app[web.1]: [1]
2018-04-05T13:46:21.390693+00:00 app[web.1]: [0] Server is running on port 5000
2018-04-05T13:46:22.929315+00:00 app[web.1]: [1] [HPM] Proxy created: function (pathname) {
2018-04-05T13:46:22.929329+00:00 app[web.1]: [1] return mayProxy(pathname) && pathname.match(context);
2018-04-05T13:46:22.929331+00:00 app[web.1]: [1] } -> http://localhost:5000
2018-04-05T13:46:22.940428+00:00 app[web.1]: [1] Starting the development server...
2018-04-05T13:46:22.940431+00:00 app[web.1]: [1]
2018-04-05T13:46:23.520069+00:00 heroku[web.1]: State changed from starting to up
2018-04-05T13:46:31.231306+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=ec7762d5-3d9d-4512-96bf-5e51fd57e531 fwd="112.134.75.196" dyno=web.1 connect=1ms service=35ms status=304 bytes=150 protocol=https
2018-04-05T13:46:32.041938+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=51901fca-b454-4e15-891f-54157d6ecffa fwd="112.134.75.196" dyno=web.1 connect=1ms service=74ms status=304 bytes=150 protocol=https
2018-04-05T13:46:34.656623+00:00 app[web.1]: [1]
2018-04-05T13:46:34.656609+00:00 app[web.1]: [1] Compiled with warnings.
2018-04-05T13:46:34.656627+00:00 app[web.1]: [1] Line 49: Expected to return a value in arrow function array-callback-return
2018-04-05T13:46:34.656629+00:00 app[web.1]: [1]
2018-04-05T13:46:34.656650+00:00 app[web.1]: [1] Search for the keywords to learn more about each warning.
2018-04-05T13:46:34.656625+00:00 app[web.1]: [1] ./src/components/currency_main.js
2018-04-05T13:46:34.656652+00:00 app[web.1]: [1] To ignore, add // eslint-disable-next-line to the line before.
2018-04-05T13:46:34.656654+00:00 app[web.1]: [1]
2018-04-05T13:47:01.000000+00:00 app[api]: Build started by user thidasaone#gmail.com
2018-04-05T13:48:18.696342+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=9b941ec9-ac57-465f-8270-ff6b576e7a7e fwd="112.134.75.196" dyno=web.1 connect=1ms service=4ms status=304 bytes=150 protocol=https
2018-04-05T13:48:19.715353+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=9dce4cdb-3251-4371-a6dc-17f5157c4c91 fwd="112.134.75.196" dyno=web.1 connect=1ms service=4ms status=200 bytes=219 protocol=https
2018-04-05T13:48:23.281435+00:00 heroku[web.1]: Restarting
2018-04-05T13:48:23.283219+00:00 heroku[web.1]: State changed from up to starting
2018-04-05T13:48:24.367174+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-04-05T13:48:24.460758+00:00 heroku[web.1]: Process exited with status 143
2018-04-05T13:48:22.235400+00:00 app[api]: Deploy f9c11456 by user thidasaone#gmail.com
2018-04-05T13:48:22.235400+00:00 app[api]: Release v9 created by user thidasaone#gmail.com
2018-04-05T13:47:01.000000+00:00 app[api]: Build succeeded
2018-04-05T13:48:31.022921+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-05T13:48:32.988916+00:00 app[web.1]:
2018-04-05T13:48:32.988939+00:00 app[web.1]: > check-market#1.0.0 start /app
2018-04-05T13:48:32.988941+00:00 app[web.1]: > node index.js
2018-04-05T13:48:32.988943+00:00 app[web.1]:
2018-04-05T13:48:33.185499+00:00 app[web.1]: Server is running on port 5000
2018-04-05T13:49:31.116916+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2018-04-05T13:49:31.093326+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 secondsof launch
2018-04-05T13:49:31.093493+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-04-05T13:49:31.174105+00:00 heroku[web.1]: Process exited with status 22
2018-04-05T13:49:31.188588+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-05T13:49:31.190801+00:00 heroku[web.1]: State changed from crashed to starting
2018-04-05T13:49:41.680073+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-05T13:49:44.021163+00:00 app[web.1]:
2018-04-05T13:49:44.021180+00:00 app[web.1]: > check-market#1.0.0 start /app
2018-04-05T13:49:44.021181+00:00 app[web.1]: > node index.js
2018-04-05T13:49:44.021183+00:00 app[web.1]:
2018-04-05T13:49:44.261412+00:00 app[web.1]: Server is running on port 5000
2018-04-05T13:50:24.659139+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=19ee5172-d09e-4a14-bec5-7332c5b8b572 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:50:42.173853+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 secondsof launch
2018-04-05T13:50:42.173971+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-04-05T13:50:42.278113+00:00 heroku[web.1]: Process exited with status 137
2018-04-05T13:50:42.292645+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-05T13:50:44.109644+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=457aceaf-7149-4cd8-aaf0-1e9746c2e7a9 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:50:46.073884+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=6d2ed2ed-a2dc-4b77-80f1-099d442e16db fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:50:55.112767+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=51e6ee29-3f28-4dc1-bc69-b58604b6524b fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:51:02.307944+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=5e366ae1-6d66-4015-85ad-e407316d083f fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:51:24.537650+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=8483caf1-1e99-4735-a16e-8df0d09b3d20 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
2018-04-05T13:51:27.770178+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=28e8927c-21ac-44c5-84e5-093f55c95aeb fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https
As I read in heroku logs, I know there's an issue (as it mentions). But I can't figure out what it is as what I've followed the same steps as before (same as I hosted other apps on Heroku)
Can anyone tell me what have I done wrong ?
P.S :
I've checked this and added Procfile and then I got an issue with React App saying Invalid Header File . So I removed it (as Heroku has made the process automatically sometime after the post)
And I checked with this as well but I don't think it'll be any help.
Try adding the config vars into your heroku app by going through
Your app => Settings => Reveal Config vars => Add PORT 5000 in it
I had the same exact issue, I have added the PORT 5000 as mentioned above, but it alone didn't resolve my issue.
Anyway by checking the build logs, I found the following error:
Error: Configuration property "mongoURI" is not defined
The production.json file was in .gitignore file, and by removing it from .gitignore and pushing it to Heroku the issue was resolved.