Heroku deployed nodejs application has issues with page navigation - node.js

//This is my server.js node file
var express=require('express')
var path=require('path')
var app=express()
var alfa=express.Router()
var port= (process.env.PORT || 5000)
app.use(express.static(__dirname+'/'))
alfa.get('/',function(req,res){
res.sendFile(path.join(__dirname+'index.html'))
});
alfa.get('/movies',function(req,res){
res.sendFile(path.join(__dirname+'movies.html'))
})
alfa.get('/shows',function(req,res){
res.sendFile(path.join(__dirname+'tvshows.html'))
})
app.use('/',alfa)
app.listen(port);
console.log('Go to the port : ' + port);
The index.html has a href to movies.html file.
Findout More...<span class="fa fa-chevron-circle-right">
After deploying to heroku cloud when running the application, the first page loads(without proper css;linked to an external css file, which is expected to be of a similar issue).
On click of the movies href link the error appears in the browser saying internal server error or page not found.
Later I checked the Heroku logs for the application and it says as below:
/app is appended before the href path movies.html
2016-01-30T00:27:06.417098+00:00 heroku[router]: at=info method=GET path="/scrol
l.js" host=alfapalakoti.herokuapp.com request_id=6b078679-71a4-436e-9b22-ab87de6
7c534 fwd="50.156.90.248" dyno=web.1 connect=1ms service=47ms status=200 bytes=6
70
2016-01-30T00:27:06.527645+00:00 heroku[router]: at=info method=GET path="/tv.pn
g" host=alfapalakoti.herokuapp.com request_id=05d76121-4af2-4d65-8425-ff4df7684a
6f fwd="50.156.90.248" dyno=web.1 connect=1ms service=14ms status=200 bytes=1499
9
2016-01-30T00:27:06.532690+00:00 heroku[router]: at=info method=GET path="/timer
.png" host=alfapalakoti.herokuapp.com request_id=5438c650-65e2-4f21-8c10-346f71c
60182 fwd="50.156.90.248" dyno=web.1 connect=1ms service=11ms status=200 bytes=2
5665
2016-01-30T00:27:06.540491+00:00 heroku[router]: at=info method=GET path="/shows
.jpg" host=alfapalakoti.herokuapp.com request_id=7afbf80b-071d-4ab1-9c18-cb36c71
f444b fwd="50.156.90.248" dyno=web.1 connect=1ms service=33ms status=200 bytes=3
69678
2016-01-30T00:27:06.625994+00:00 heroku[router]: at=info method=GET path="/carou
selbg.jpg" host=alfapalakoti.herokuapp.com request_id=2c371ea0-d47b-46e2-b9a1-51
28fbfaba4a fwd="50.156.90.248" dyno=web.1 connect=1ms service=112ms status=200 b
ytes=2069053
2016-01-30T00:27:06.781953+00:00 heroku[router]: at=info method=GET path="/mainb
g.jpg" host=alfapalakoti.herokuapp.com request_id=e43a6ac3-0b68-40f6-95ba-edc988
a57a91 fwd="50.156.90.248" dyno=web.1 connect=1ms service=6ms status=200 bytes=1
1178
2016-01-30T00:27:06.623717+00:00 heroku[router]: at=info method=GET path="/movie
s.jpg" host=alfapalakoti.herokuapp.com request_id=61d32aa0-0158-4962-8f8c-5f1a30
2e8654 fwd="50.156.90.248" dyno=web.1 connect=1ms service=259ms status=200 bytes
=4974518
2016-01-30T00:27:16.482080+00:00 heroku[router]: at=info method=GET path="/movie
s" host=alfapalakoti.herokuapp.com request_id=efc2a66c-6ec0-4e76-9afb-39384b8513
52 fwd="50.156.90.248" dyno=web.1 connect=1ms service=14ms status=404 bytes=208
2016-01-30T00:27:16.492630+00:00 app[web.1]: Error: ENOENT: no such file or dire
ctory, stat '**/appmovies.html'**
2016-01-30T00:27:16.492634+00:00 app[web.1]: at Error (native)
2016-01-30T01:00:47.163686+00:00 heroku[web.1]: State changed from up to down
2016-01-30T01:00:47.162812+00:00 heroku[web.1]: Idling
2016-01-30T01:00:54.049172+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-01-30T01:00:57.704556+00:00 heroku[web.1]: Process exited with status 143
//can someone please help me with this?
//why is that being added? How to get rid of it?

Related

App is deployed to heroku but returns a server error

I have my application working perfectly when I run it locally. However, once it was deployed to Heroku, the server stopped returning the data and returns a 500 code. All of my code can be found here and the live application (not functioning) is here.
EDIT:
Here are the heroku logs:
2021-03-06T04:00:59.416851+00:00 heroku[router]: at=info method=GET path="/" host=fast-shore-66611.herokuapp.com request_id=0a279e6e-c6d0-4bf8-ac4d-45d85c914e4a fwd="174.45.175.167"
dyno=web.1 connect=1ms service=50ms status=200 bytes=1401 protocol=https
2021-03-06T04:00:59.672729+00:00 heroku[router]: at=info method=GET path="/js/app.71b734f2.js" host=fast-shore-66611.herokuapp.com request_id=68509950-00e2-4f0d-84ea-3a96cf0dcbc1 fwd="174.45.175.167" dyno=web.1 connect=1ms service=21ms status=200 bytes=62457 protocol=https2021-03-06T04:01:00.023258+00:00 heroku[router]: at=info method=GET path="/css/app.badeae52.css" host=fast-shore-66611.herokuapp.com request_id=603ee68a-bc30-4c7e-8177-3e3c0f3fa712 fwd="174.45.175.167" dyno=web.1 connect=0ms service=22ms status=200 bytes=3523 protocol=https
2021-03-06T04:01:00.035863+00:00 heroku[router]: at=info method=GET path="/js/chunk-vendors.e9c4f783.js" host=fast-shore-66611.herokuapp.com request_id=8e857b3a-b40d-4ad8-a1aa-cb8dc6d3b15a fwd="174.45.175.167" dyno=web.1 connect=0ms service=39ms status=200 bytes=501256 protocol=https
2021-03-06T04:01:04.003747+00:00 heroku[router]: at=info method=GET path="/result/tyler" host=fast-shore-66611.herokuapp.com request_id=45020e4f-61d5-419d-9a51-f61ccb06b257 fwd="174.45.175.167" dyno=web.1 connect=0ms service=21ms status=500 bytes=284 protocol=https
2021-03-06T04:01:08.110920+00:00 heroku[router]: at=info method=GET path="/result/henderson" host=fast-shore-66611.herokuapp.com request_id=e9f739c3-36cb-4d3e-a480-e93d0784ea66 fwd="174.45.175.167" dyno=web.1 connect=0ms service=17ms status=500 bytes=284 protocol=https
2021-03-06T04:01:33.000000+00:00 app[api]: Build started by user reaganclayton1995#gmail.com
2021-03-06T04:01:38.112111+00:00 heroku[router]: at=info method=GET path="/result/tyler" host=fast-shore-66611.herokuapp.com request_id=f8a0dd9a-a033-430a-8249-6f433b6066a5 fwd="174.45.175.167" dyno=web.1 connect=0ms service=45ms status=500 bytes=284 protocol=https
2021-03-06T04:01:40.977816+00:00 heroku[router]: at=info method=GET path="/result/tyler" host=fast-shore-66611.herokuapp.com request_id=305a750b-8ca6-486c-9cee-a7b9b3e64891 fwd="174.45.175.167" dyno=web.1 connect=0ms service=9ms status=500 bytes=284 protocol=https
2021-03-06T04:01:46.859981+00:00 heroku[router]: at=info method=GET path="/" host=fast-shore-66611.herokuapp.com request_id=738c1e2e-ed83-4fef-86e3-52813667b798 fwd="174.45.175.167"
dyno=web.1 connect=0ms service=3ms status=304 bytes=269 protocol=https
2021-03-06T04:01:47.095156+00:00 heroku[router]: at=info method=GET path="/js/app.71b734f2.js" host=fast-shore-66611.herokuapp.com request_id=aa992042-2411-439d-b982-e180501f2e07 fwd="174.45.175.167" dyno=web.1 connect=1ms service=8ms status=304 bytes=270 protocol=https
2021-03-06T04:01:47.101684+00:00 heroku[router]: at=info method=GET path="/css/app.badeae52.css" host=fast-shore-66611.herokuapp.com request_id=aad26a97-869d-450b-9d14-b1deac43a470 fwd="174.45.175.167" dyno=web.1 connect=0ms service=30ms status=200 bytes=3523 protocol=https
2021-03-06T04:01:47.157018+00:00 heroku[router]: at=info method=GET path="/js/chunk-vendors.e9c4f783.js" host=fast-shore-66611.herokuapp.com request_id=4eb14331-e0c3-4127-b691-0f036cca30a4 fwd="174.45.175.167" dyno=web.1 connect=0ms service=59ms status=304 bytes=271 protocol=https
2021-03-06T04:02:07.327105+00:00 app[api]: Deploy 36a0a5b6 by user reaganclayton1995#gmail.com
2021-03-06T04:02:07.327105+00:00 app[api]: Release v10 created by user reaganclayton1995#gmail.com
2021-03-06T04:02:07.516033+00:00 heroku[web.1]: Restarting
2021-03-06T04:02:07.541614+00:00 heroku[web.1]: State changed from up to starting
2021-03-06T04:02:08.000000+00:00 app[api]: Build succeeded
2021-03-06T04:02:09.003004+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-03-06T04:02:09.247345+00:00 heroku[web.1]: Process exited with status 143
2021-03-06T04:02:09.633378+00:00 heroku[web.1]: Starting process with command `npm start`
2021-03-06T04:02:12.908565+00:00 app[web.1]:
2021-03-06T04:02:12.908594+00:00 app[web.1]: > weatherup#1.0.0 start
2021-03-06T04:02:12.908594+00:00 app[web.1]: > node server
2021-03-06T04:02:12.908595+00:00 app[web.1]:
2021-03-06T04:02:13.113839+00:00 app[web.1]: Server running in production mode on port 39626
2021-03-06T04:02:13.917299+00:00 heroku[web.1]: State changed from starting to up
2021-03-06T04:09:34.447563+00:00 heroku[router]: at=info method=GET path="/" host=fast-shore-66611.herokuapp.com request_id=b591ded0-7f1a-4c14-a1e2-7f856a2e45aa fwd="54.164.83.156" dyno=web.1 connect=1ms service=24ms status=200 bytes=1401 protocol=https
2021-03-06T04:10:06.594714+00:00 heroku[router]: at=info method=HEAD path="/" host=fast-shore-66611.herokuapp.com request_id=b063d8b0-d361-40a2-a0e8-85b2ac937292 fwd="217.182.175.162" dyno=web.1 connect=0ms service=2ms status=200 bytes=321 protocol=https
2021-03-06T04:11:00.259797+00:00 heroku[router]: at=info method=GET path="/result/tyler" host=fast-shore-66611.herokuapp.com request_id=216b9449-8ad7-4bf4-8780-99d3db9ea0c0 fwd="174.45.175.167" dyno=web.1 connect=1ms service=7ms status=500 bytes=284 protocol=https
2021-03-06T04:11:03.661150+00:00 heroku[router]: at=info method=GET path="/result/henderson" host=fast-shore-66611.herokuapp.com request_id=9b656dd6-dccc-4271-a507-2181e358193d fwd="174.45.175.167" dyno=web.1 connect=1ms service=3ms status=500 bytes=284 protocol=https
EDIT 2:
It turns out that I had my config.env added to my .gitignore, so my server didn't have access to my environment variables to make the API call. Now I am wondering if taking it out of the .gitignore is going to allow users to access the file, which is what I don't want.
Follows these steps which is given in image, That's a right way to deploy app on Heroku

Socket.io is working on Local Host but not Heroku

I managed to get sockets to work on my LocalHost, however when uploading to Heroku I get the following errors.
Heroku logs:
2020-02-26T19:18:12.223451+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xsN8" host=evening-beach-84352.herokuapp.com request_id=9e085385-d06d-42f8-a02b-741ebdb50139 fwd="99.239.140.92" dyno=web.1 connect=1ms service=7ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:16.268249+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtMN" host=evening-beach-84352.herokuapp.com request_id=560a1283-e9ad-4f98-b65d-c98e3af0d989 fwd="99.239.140.92" dyno=web.1 connect=1ms service=7ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:16.340518+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtNI" host=evening-beach-84352.herokuapp.com request_id=0747c99f-bfa7-4a48-9dc9-396237ea4afd fwd="99.239.140.92" dyno=web.1 connect=1ms service=17ms status=404 bytes=417 protocol=https
2020-02-26T19:18:16.345722+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtNd" host=evening-beach-84352.herokuapp.com request_id=c28aa30e-c33f-4d2b-809d-7f723c9ad2f8 fwd="99.239.140.92" dyno=web.1 connect=1ms service=11ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:16.394512+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtOS" host=evening-beach-84352.herokuapp.com request_id=93635a58-6c21-4d1a-81b4-ba67c712bc4a fwd="99.239.140.92" dyno=web.1 connect=1ms service=3ms status=404 bytes=417 protocol=https
2020-02-26T19:18:18.146871+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtpq" host=evening-beach-84352.herokuapp.com request_id=8dc8077a-5719-4f97-bd60-dc2f9585efea fwd="99.239.140.92" dyno=web.1 connect=1ms service=5ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:18.104971+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtp6" host=evening-beach-84352.herokuapp.com request_id=1a135498-5911-4757-90a6-52f22188b3ae fwd="99.239.140.92" dyno=web.1 connect=1ms service=8ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:18.174618+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtqB" host=evening-beach-84352.herokuapp.com request_id=dce824bb-5243-45be-bd9b-5be3026412ac fwd="99.239.140.92" dyno=web.1 connect=1ms service=3ms status=404 bytes=417 protocol=https
2020-02-26T19:18:18.235090+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtr2" host=evening-beach-84352.herokuapp.com request_id=44dbc61d-5e40-4283-b602-77107c20bdcd fwd="99.239.140.92" dyno=web.1 connect=1ms service=7ms status=404 bytes=417 protocol=https
Browser console logs:
polling-xhr.js:271 POST https://evening-beach-84352.herokuapp.com/socket.io/?EIO=3&transport=polling&t=N22yWHd 404 (Not Found)
I have this set up on my client side code:
import socketIOClient from "socket.io-client";
const socket = socketIOClient("https://evening-beach-84352.herokuapp.com/")
And this one my server side code:
const server = require('http').Server(app);
const socketIO = require('socket.io')
const io = socketIO(server, { origin: "*:*" });
const PORT = process.env.PORT || 8080;
Have you enabled session affinity in your app? From the support article:
Apps using Socket.io should enable session affinity. If you plan to
use Node’s Cluster module or to scale your app to multiple dynos, you
should also follow Socket.io’s multiple-nodes instructions.
heroku features:enable http-session-affinity
I just started using Heroku recently and just added socket.io to my application and am seeing similar errors. Yesterday they went away, today they are back. I have two tabs in my browser 1 works the other doesn't...
The difference: http vs https
When you click the link in Heroku to take you to your app it navigates to https://myapp.herokuapp.com but if I manually navigate to http://myapp.herokuapp.com suddenly all the errors go away.
Now I'd like to know the reason why one works and the other doesn't...

forge.tutorial.viewhubmodels.nodejs tutorial 401 (Unauthorized) on Heroku

I did the http://learnforge.autodesk.io tutorial and locally the apps work fine. But when I try to deploy the forge.tutorial.viewhubmodels.nodejs app to Heroku I get the following error when I try to log in:
GET https://forgebcsample.herokuapp.com/api/forge/oauth/token 401 (Unauthorized)
The Config Vars are correct in the Heroku dashboard and I updated the values at the Forge Developer Portal as it is described in the tutorial under deployment. I even tried hardcoding the FORGE_CLIENT_ID, FORGE_CLIENT_SECRET and FORGE_CALLBACK_URL into the app but the error still persists.
Heroku Log:
2018-09-07T06:59:41.950470+00:00 heroku[router]: at=info method=GET path="/" host=forgebcsample.herokuapp.com request_id=6ef8e0d2-d814-478a-bbe2-e624789aceee fwd="202.148.226.254" dyno=web.1 connect=1ms service=2ms status=304 bytes=237 protocol=https
2018-09-07T06:59:42.215849+00:00 heroku[router]: at=info method=GET path="/js/ForgeTree.js" host=forgebcsample.herokuapp.com request_id=6d58c9c0-afce-4c44-b1e0-f9d40326c607 fwd="202.148.226.254" dyno=web.1 connect=1ms service=2ms status=304 bytes=238 protocol=https
2018-09-07T06:59:42.214891+00:00 heroku[router]: at=info method=GET path="/css/main.css" host=forgebcsample.herokuapp.com request_id=66be297d-0707-4e5d-8c6a-c4fb269c11f0 fwd="202.148.226.254" dyno=web.1 connect=1ms service=2ms status=304 bytes=237 protocol=https
2018-09-07T06:59:42.453624+00:00 heroku[router]: at=info method=GET path="/js/ForgeViewer.js" host=forgebcsample.herokuapp.com request_id=bc8f0050-1ca2-46b9-84be-d1e36c8afcf4 fwd="202.148.226.254" dyno=web.1 connect=1ms service=4ms status=304 bytes=237 protocol=https
2018-09-07T06:59:43.486820+00:00 heroku[router]: at=info method=GET path="/api/forge/oauth/token" host=forgebcsample.herokuapp.com request_id=d6acdca3-1424-48b9-9480-d0497af58179 fwd="202.148.226.254" dyno=web.1 connect=1ms service=2ms status=401 bytes=127 protocol=https
2018-09-07T07:00:51.391643+00:00 heroku[router]: at=info method=GET path="/api/forge/oauth/url" host=forgebcsample.herokuapp.com request_id=ab185f67-7288-43ce-bdf7-9551b8771bba fwd="202.148.226.254" dyno=web.1 connect=1ms service=2ms status=200 bytes=382 protocol=https
2018-09-07T07:00:58.551942+00:00 heroku[router]: at=info method=GET path="/api/forge/callback/oauth?code=46TAvefGUSv_xZ6cTJKzyx-t-HT6Y2FzvDyzZQIS" host=forgebcsample.herokuapp.com request_id=b67abc9f-419e-47d3-892a-3fcc6fbf7f7d fwd="202.148.226.254" dyno=web.1 connect=1ms service=227ms status=302 bytes=234 protocol=https
2018-09-07T07:00:58.808686+00:00 heroku[router]: at=info method=GET path="/" host=forgebcsample.herokuapp.com request_id=1a2ff1de-513e-40e2-a73a-0b48781a06bc fwd="202.148.226.254" dyno=web.1 connect=1ms service=17ms status=304 bytes=237 protocol=https
2018-09-07T07:00:59.082869+00:00 heroku[router]: at=info method=GET path="/css/main.css" host=forgebcsample.herokuapp.com request_id=428a5759-895f-45e5-a9db-48d8721889c0 fwd="202.148.226.254" dyno=web.1 connect=1ms service=5ms status=304 bytes=237 protocol=https
2018-09-07T07:00:59.325093+00:00 heroku[router]: at=info method=GET path="/js/ForgeTree.js" host=forgebcsample.herokuapp.com request_id=04a300dc-8697-4097-8c06-1788e21db69d fwd="202.148.226.254" dyno=web.1 connect=1ms service=3ms status=304 bytes=238 protocol=https
2018-09-07T07:00:59.822084+00:00 heroku[router]: at=info method=GET path="/js/ForgeViewer.js" host=forgebcsample.herokuapp.com request_id=c601f61e-cfea-4738-8837-540941adaf96 fwd="202.148.226.254" dyno=web.1 connect=1ms service=11ms status=304 bytes=237 protocol=https
2018-09-07T07:01:00.157419+00:00 heroku[router]: at=info method=GET path="/api/forge/oauth/token" host=forgebcsample.herokuapp.com request_id=77b86dc0-50c7-429e-ade9-82e1b8fa56db fwd="202.148.226.254" dyno=web.1 connect=1ms service=2ms status=401 bytes=127 protocol=https
The 401 is expected until you sign in, then it should return 200
I tried run your herokuapp, but could not sign in as the callback url is not properly set. Please make sure it uses the exact same value as on your Forge app.
EDIT
Can try comment the following line on start.js
secure: (process.env.NODE_ENV === 'production'),

New Sails.js app gets infinite redirect in Heroku

I had created an empty application with Sails.js ver. 1.0.2. I used a 'Web App' option of 'sails new' command. It works fine, when started at localhost, both in development and production environments.
Next, I want to put this application into Heroku.
What I've done:
created new app in Heroku with "heroku create";
initialized new git repo in my application root;
created Procfile in my app root with text: "web: npm start"
changed production environment config (in \config\env\production.js):
Changed sockets.onlyAllowOrigins and custom.baseUrl values to "http://myappname.herokuapp.com"
Changed http.trustProxy value to "true"
set heroku remote for my repo with "heroku git:remote -a myappname"
added, committed and pushed my repo to Heroku with "git push heroku master"
It builds successfully with some warnings, but the worst thing is that app is not working. Each requests causes redirect loop with heroku[router] to the same address.
Here is a part of Heroku log:
2018-05-16T12:52:25.991036+00:00 app[web.1]: debug: -------------------------------------------------------
2018-05-16T12:52:25.991290+00:00 app[web.1]: debug: :: Wed May 16 2018 12:52:25 GMT+0000 (UTC)
2018-05-16T12:52:25.991366+00:00 app[web.1]: debug: Environment : production
2018-05-16T12:52:25.991441+00:00 app[web.1]: debug: Port : 37749
2018-05-16T12:52:25.991589+00:00 app[web.1]: debug: -------------------------------------------------------
2018-05-16T12:52:26.645022+00:00 heroku[web.1]: State changed from starting to up
2018-05-16T12:52:27.762757+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=ee575a91-305f-4518-af9f-537ceccbc3cf fwd="83.45.25.57" dyno=web.1 connect=2ms service=48ms status=302 bytes=523 protocol=https
2018-05-16T12:52:28.039174+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=980d6e72-b03c-4704-af97-56c7f9debc8b fwd="83.45.25.57" dyno=web.1 connect=0ms service=9ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.185571+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=b46a235f-fbf7-4404-a4b7-0a95bb1a0254 fwd="83.45.25.57" dyno=web.1 connect=1ms service=5ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.339593+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=03bbd460-3200-4158-a555-33c20262a212 fwd="83.45.25.57" dyno=web.1 connect=2ms service=7ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.484756+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=af7303b1-f04c-431b-93b5-9e8b148a6721 fwd="83.45.25.57" dyno=web.1 connect=1ms service=4ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.637541+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=1535454e-58b0-41d2-821d-317d7ebabeeb fwd="83.45.25.57" dyno=web.1 connect=4ms service=8ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.788965+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=559d3426-78b9-4b65-8063-c44eb728d825 fwd="83.45.25.57" dyno=web.1 connect=1ms service=6ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.936187+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=e4ad129d-746b-490c-9d0d-c77966b98d46 fwd="83.45.25.57" dyno=web.1 connect=1ms service=7ms status=302 bytes=360 protocol=http
2018-05-16T12:52:29.082496+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=92a66cab-344e-410d-9ebf-8c8bddec80bd fwd="83.45.25.57" dyno=web.1 connect=2ms service=5ms status=302 bytes=360 protocol=http
2018-05-16T12:52:29.233773+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=92f3734c-6e37-48d6-9849-807b53f1e1f7 fwd="83.45.25.57" dyno=web.1 connect=1ms service=5ms status=302 bytes=360 protocol=http
Tried to set custom.baseUrl as HTTP and HTTPS with no difference.
Where did things go wrong?
#marvin, you don't need to create a Procfile in heroku.
just when you deploy your app it will run automatically and set environment production.

One page of my website related to the db doesn't work UnhandledPromiseRejectionWarning

I just created this website https://m-landscape.herokuapp.com/ using node.js and mongoDB, but the gallery route that uses the db doesn't load at all even though it loads perfectly when I run it on the terminal. How can I solve this?
This is what I get when I type heroku logs:
2017-08-12T05:15:14.128733+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=f5354a5c-df9b-469b-a69f-a2743e2922d9 fwd="156.205.87.209" dyno=web.1 connect=1ms service=11ms status=200 bytes=9046 protocol=https
2017-08-12T05:15:26.637696+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=cbeb8fa7-bd03-47c0-aa76-c8e1cfc70c40 fwd="156.205.87.209" dyno=web.1 connect=1ms service=27ms status=304 bytes=152 protocol=https
2017-08-12T05:15:26.846189+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=18ec3a58-3528-49c8-af99-4f7bc28e810a fwd="156.205.87.209" dyno=web.1 connect=2ms service=4ms status=304 bytes=238 protocol=https
2017-08-12T05:15:58.831552+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=c15d0000-166c-4705-ad1a-116e6985744c fwd="156.205.87.209" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
2017-08-12T05:16:19.533667+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=c3e8adba-f14a-4cc3-8106-58215e3364d3 fwd="156.205.87.209" dyno=web.1 connect=0ms service=7ms status=304 bytes=152 protocol=https
2017-08-12T05:16:19.727921+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=6024122e-8f8b-49e5-9392-1e1591a526d1 fwd="156.205.87.209" dyno=web.1 connect=1ms service=5ms status=304 bytes=238 protocol=https
2017-08-12T05:16:19.883184+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=070b690a-5701-4e66-9432-b065f272a983 fwd="156.205.87.209" dyno=web.1 connect=1ms service=5ms status=304 bytes=237 protocol=https
2017-08-12T05:16:22.930272+00:00 heroku[router]: at=info method=GET path="/about" host=m-landscape.herokuapp.com request_id=c0ca728f-bad6-4d4a-84d3-cb57f77908f9 fwd="156.205.87.209" dyno=web.1 connect=1ms service=7ms status=200 bytes=3960 protocol=https
2017-08-12T05:16:23.155574+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=2d97c8dd-12e4-4d27-a889-2a80309eefc7 fwd="156.205.87.209" dyno=web.1 connect=1ms service=3ms status=304 bytes=237 protocol=https
2017-08-12T05:16:24.462197+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=5048db82-f696-4df2-9bc0-cbb913e33b9e fwd="156.205.87.209" dyno=web.1 connect=1ms service=30003ms status=503 bytes=0 protocol=https
2017-08-12T05:16:26.383545+00:00 heroku[router]: at=info method=GET path="/contact" host=m-landscape.herokuapp.com request_id=b9c3c474-690f-49b4-a47b-c75f1e4d2703 fwd="156.205.87.209" dyno=web.1 connect=1ms service=43ms status=200 bytes=4389 protocol=https
2017-08-12T05:16:26.568909+00:00 heroku[router]: at=info method=GET path="/stylesheets/carousel.js" host=m-landscape.herokuapp.com request_id=91ce952f-1e70-4772-8d8d-2cb160d476ea fwd="156.205.87.209" dyno=web.1 connect=0ms service=8ms status=200 bytes=1081 protocol=https
2017-08-12T05:16:26.571180+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=ab6ba94b-257c-4551-a666-68f388c41883 fwd="156.205.87.209" dyno=web.1 connect=0ms service=6ms status=304 bytes=238 protocol=https
2017-08-12T05:16:26.724769+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=56143662-9bfa-4691-b805-057cf1ba2bbf fwd="156.205.87.209" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2017-08-12T05:16:28.616171+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=16ffaef7-2cdc-451b-9664-fee284f09168 fwd="156.205.87.209" dyno=web.1 connect=1ms service=6ms status=304 bytes=152 protocol=https
2017-08-12T05:16:28.839862+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=1935e544-9a9f-4877-8dfb-6b04584c14dc fwd="156.205.87.209" dyno=web.1 connect=1ms service=5ms status=304 bytes=237 protocol=https
2017-08-12T05:16:28.809192+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=cd2f0e1a-7ce8-436d-b375-09064fe9a965 fwd="156.205.87.209" dyno=web.1 connect=1ms service=3ms status=304 bytes=238 protocol=https
2017-08-12T05:16:36.494340+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=8fd57def-1c51-40eb-b6e0-70a889eb2ba3 fwd="156.205.87.209" dyno=web.1 connect=1ms service=12ms status=304 bytes=238 protocol=https
2017-08-12T05:51:35.947070+00:00 heroku[web.1]: Idling
2017-08-12T05:51:35.947708+00:00 heroku[web.1]: State changed from up to down
2017-08-12T05:51:36.511865+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-08-12T05:51:36.997605+00:00 heroku[web.1]: Process exited with status 143
2017-08-12T06:38:52.403440+00:00 heroku[web.1]: Unidling
2017-08-12T06:38:52.403705+00:00 heroku[web.1]: State changed from down to starting
2017-08-12T06:38:55.933091+00:00 app[web.1]:
2017-08-12T06:38:55.933104+00:00 app[web.1]: > mlandscape#1.0.0 start /app
2017-08-12T06:38:55.933105+00:00 app[web.1]: > node app.js
2017-08-12T06:38:55.933105+00:00 app[web.1]:
2017-08-12T06:38:56.820635+00:00 app[web.1]: (node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
2017-08-12T06:38:56.805440+00:00 app[web.1]: Server Has started!
2017-08-12T06:38:57.172006+00:00 heroku[web.1]: State changed from starting to up
2017-08-12T06:38:57.508778+00:00 heroku[router]: at=info method=GET path="/" host=m-landscape.herokuapp.com request_id=7dfafe17-7ad1-4661-965f-a9619d81f9ac fwd="106.51.44.4" dyno=web.1 connect=0ms service=31ms status=200 bytes=1368 protocol=https
2017-08-12T06:38:57.767218+00:00 heroku[router]: at=info method=GET path="/stylesheets/landing.css" host=m-landscape.herokuapp.com request_id=2ccf85d4-a4c1-4e46-98bb-e36d8367fc4d fwd="106.51.44.4" dyno=web.1 connect=0ms service=13ms status=200 bytes=3019 protocol=https
2017-08-12T06:39:00.017724+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=m-landscape.herokuapp.com request_id=d42c4bc2-05b0-4ab6-93ba-f33e44ca2a89 fwd="106.51.44.4" dyno=web.1 connect=0ms service=4ms status=404 bytes=394 protocol=https
2017-08-12T06:39:03.547711+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=f65b688e-e049-426a-9023-be3d2856ec3b fwd="106.51.44.4" dyno=web.1 connect=0ms service=18ms status=200 bytes=4843 protocol=https
2017-08-12T06:39:03.829895+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=189778ef-7c68-4a6f-9351-90a230bbccf1 fwd="106.51.44.4" dyno=web.1 connect=0ms service=10ms status=200 bytes=9046 protocol=https
2017-08-12T06:39:04.300052+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=9f1a9599-c049-4225-84a4-e9f4d26cf7b3 fwd="106.51.44.4" dyno=web.1 connect=0ms service=4ms status=200 bytes=643 protocol=https
2017-08-12T06:39:43.363816+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=b4e12d06-9031-4752-bcf3-cc06fe514d48 fwd="106.51.44.4" dyno=web.1 connect=0ms service=30002ms status=503 bytes=0 protocol=https
2017-08-12T06:40:02.177981+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=e661f8e4-5adb-43e9-8849-5abba31aa383 fwd="106.51.44.4" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2017-08-12T06:40:08.415934+00:00 heroku[router]: at=info method=GET path="/about" host=m-landscape.herokuapp.com request_id=43bd30cd-24fc-4dd8-8983-c430b7bb4e7c fwd="106.51.44.4" dyno=web.1 connect=0ms service=21ms status=200 bytes=3960 protocol=https
2017-08-12T06:40:08.876406+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=3091b383-e341-4b41-b678-9329cf03af0c fwd="106.51.44.4" dyno=web.1 connect=0ms service=3ms status=304 bytes=238 protocol=https
2017-08-12T06:40:08.984804+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=9761b955-8efa-48ce-bea7-1ead860c9fd8 fwd="106.51.44.4" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2017-08-12T06:40:20.964435+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=1a61802e-8247-4804-8d2d-d1466f72b52d fwd="106.51.44.4" dyno=web.1 connect=0ms service=1ms status=304 bytes=238 protocol=https
2017-08-12T06:40:20.970408+00:00 heroku[router]: at=info method=GET path="/stylesheets/carousel.js" host=m-landscape.herokuapp.com request_id=2ca57b4a-3694-4d1e-9591-57a658a2cf5b fwd="106.51.44.4" dyno=web.1 connect=0ms service=3ms status=200 bytes=1081 protocol=https
2017-08-12T06:40:21.223340+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=16d6b9fc-b206-4bdb-b444-0a1f9a66d73f fwd="106.51.44.4" dyno=web.1 connect=0ms service=1ms status=304 bytes=237 protocol=https
2017-08-12T06:41:10.883534+00:00 heroku[router]: at=info method=GET path="/" host=m-landscape.herokuapp.com request_id=76ccb562-c56d-424d-afa7-9ddf0ec1bcb2 fwd="106.51.44.4" dyno=web.1 connect=0ms service=4ms status=304 bytes=151 protocol=https
2017-08-12T06:41:11.231218+00:00 heroku[router]: at=info method=GET path="/stylesheets/landing.css" host=m-landscape.herokuapp.com request_id=71f42453-b548-4f4c-a8f5-3c76834070e7 fwd="106.51.44.4" dyno=web.1 connect=0ms service=1ms status=304 bytes=237 protocol=https
2017-08-12T06:41:17.521008+00:00 heroku[router]: at=info method=GET path="/stylesheets/landing.css" host=m-landscape.herokuapp.com request_id=dcb8bed6-9837-456b-a57b-75a09fdc9e45 fwd="106.51.44.4" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2017-08-12T07:01:36.159161+00:00 heroku[router]: at=info method=GET path="/" host=m-landscape.herokuapp.com request_id=0f3d182d-6030-4b49-8a1c-b8b653f89468 fwd="47.157.80.30" dyno=web.1 connect=0ms service=5ms status=200 bytes=1368 protocol=https
2017-08-12T07:01:36.261814+00:00 heroku[router]: at=info method=GET path="/stylesheets/landing.css" host=m-landscape.herokuapp.com request_id=797471f0-84b2-4412-a972-05cabe0cb5fb fwd="47.157.80.30" dyno=web.1 connect=4ms service=4ms status=200 bytes=3019 protocol=https
2017-08-12T07:01:36.652817+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=m-landscape.herokuapp.com request_id=81de5fa8-a3a4-4ed3-99a9-80cf948297a3 fwd="47.157.80.30" dyno=web.1 connect=0ms service=2ms status=404 bytes=394 protocol=https
2017-08-12T07:01:40.512549+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=2eb8080a-c715-4f03-94fc-e5ae917dac4f fwd="47.157.80.30" dyno=web.1 connect=0ms service=3ms status=200 bytes=9046 protocol=https
2017-08-12T07:01:40.412190+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=88f74ab0-eba8-477c-8d86-8793561592ec fwd="47.157.80.30" dyno=web.1 connect=0ms service=4ms status=200 bytes=4843 protocol=https
2017-08-12T07:01:40.593098+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=fefa455e-7694-41a1-a112-bf4db046486f fwd="47.157.80.30" dyno=web.1 connect=0ms service=3ms status=200 bytes=643 protocol=https
2017-08-12T07:01:48.798622+00:00 heroku[router]: at=info method=GET path="/contact" host=m-landscape.herokuapp.com request_id=d5396f98-360e-46c0-b2d6-7bf8181ef06b fwd="47.157.80.30" dyno=web.1 connect=0ms service=3ms status=200 bytes=4389 protocol=https
2017-08-12T07:01:48.888013+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=e6c6a956-2be6-401c-90f5-a62bf07e8d3b fwd="47.157.80.30" dyno=web.1 connect=0ms service=1ms status=304 bytes=238 protocol=https
2017-08-12T07:01:49.036670+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=4923d962-d176-47e6-ac5c-00155c6af993 fwd="47.157.80.30" dyno=web.1 connect=0ms service=2ms status=304 bytes=237 protocol=https
2017-08-12T07:01:48.965879+00:00 heroku[router]: at=info method=GET path="/stylesheets/carousel.js" host=m-landscape.herokuapp.com request_id=724bf8ec-9e4f-4238-b88f-5796f26f1a62 fwd="47.157.80.30" dyno=web.1 connect=0ms service=3ms status=200 bytes=1081 protocol=https
2017-08-12T07:38:08.262854+00:00 heroku[web.1]: Idling
2017-08-12T07:38:08.263608+00:00 heroku[web.1]: State changed from up to down
2017-08-12T07:38:08.919893+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-08-12T07:38:09.065149+00:00 heroku[web.1]: Process exited with status 143
2017-08-12T09:52:59.211302+00:00 heroku[web.1]: Unidling
2017-08-12T09:52:59.211519+00:00 heroku[web.1]: State changed from down to starting
2017-08-12T09:53:00.859568+00:00 heroku[web.1]: Starting process with command `npm start`
2017-08-12T09:53:03.395411+00:00 app[web.1]:
2017-08-12T09:53:03.395432+00:00 app[web.1]: > node app.js
2017-08-12T09:53:03.395431+00:00 app[web.1]: > mlandscape#1.0.0 start /app
2017-08-12T09:53:03.395433+00:00 app[web.1]:
2017-08-12T09:53:04.061041+00:00 app[web.1]: Server Has started!
2017-08-12T09:53:04.071270+00:00 app[web.1]: (node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
2017-08-12T09:53:04.479277+00:00 heroku[web.1]: State changed from starting to up
2017-08-12T09:53:05.293715+00:00 heroku[router]: at=info method=GET path="/" host=m-landscape.herokuapp.com request_id=9b313b6e-57ab-4fb1-be59-4aab4dee39fc fwd="62.143.18.213" dyno=web.1 connect=1ms service=29ms status=200 bytes=1368 protocol=https
2017-08-12T09:53:05.479942+00:00 heroku[router]: at=info method=GET path="/stylesheets/landing.css" host=m-landscape.herokuapp.com request_id=89fc8125-a304-4a9d-a638-825d6975f724 fwd="62.143.18.213" dyno=web.1 connect=1ms service=12ms status=200 bytes=3019 protocol=https
2017-08-12T09:53:06.171863+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=m-landscape.herokuapp.com request_id=4d420621-0012-4368-80a9-54ab33827afa fwd="62.143.18.213" dyno=web.1 connect=1ms service=11ms status=404 bytes=394 protocol=https
2017-08-12T09:53:07.765206+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=f06fc16f-00b9-4415-89e5-3722d12fa5b7 fwd="62.143.18.213" dyno=web.1 connect=1ms service=9ms status=200 bytes=4843 protocol=https
2017-08-12T09:53:08.024507+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=d9a59713-c3e0-4071-884c-94b1b38c62a1 fwd="62.143.18.213" dyno=web.1 connect=1ms service=6ms status=200 bytes=9046 protocol=https
2017-08-12T09:53:08.169819+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=2fdc9b30-8edb-40b3-b9ba-6ed40026cca9 fwd="62.143.18.213" dyno=web.1 connect=1ms service=3ms status=200 bytes=643 protocol=https
2017-08-12T09:53:43.130952+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=ff4184c2-37d7-4b5d-be06-ba8492c2ab09 fwd="62.143.18.213" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
2017-08-12T09:53:47.822008+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=9b8caefa-90d5-4002-94d2-f4205b755a26 fwd="62.143.18.213" dyno=web.1 connect=2ms service=30001ms status=503 bytes=0 protocol=https
2017-08-12T10:09:05.250236+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=dd726556-be36-44f8-88d3-eb0f26950c08 fwd="160.160.128.160" dyno=web.1 connect=0ms service=10ms status=200 bytes=4843 protocol=http
2017-08-12T10:09:05.551041+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=e30d6674-7391-4b5b-a089-00eade149f6b fwd="160.160.128.160" dyno=web.1 connect=0ms service=5ms status=200 bytes=9046 protocol=http
2017-08-12T10:09:05.558471+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=b01cec18-1e66-401d-ad6e-8c55bf42a261 fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=200 bytes=643 protocol=http
2017-08-12T10:09:07.812358+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=m-landscape.herokuapp.com request_id=d1eacd19-ca82-4d77-a0c2-87c5df636d1d fwd="160.160.128.160" dyno=web.1 connect=0ms service=3ms status=404 bytes=394 protocol=http
2017-08-12T10:09:14.011958+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=fe939fa0-0f57-4a83-a1ce-f76f29321386 fwd="160.160.128.160" dyno=web.1 connect=0ms service=9ms status=304 bytes=152 protocol=http
2017-08-12T10:09:14.255774+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=c2e19b70-a593-417d-b955-48e99e268a81 fwd="160.160.128.160" dyno=web.1 connect=5ms service=5ms status=304 bytes=238 protocol=http
2017-08-12T10:09:14.393196+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=f6b82373-a2e4-4af9-8b15-b051697181e6 fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=304 bytes=237 protocol=http
2017-08-12T10:09:40.658365+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/gallery" host=m-landscape.herokuapp.com request_id=3db8b0f7-e518-4fc5-ac93-a128cd4f5034 fwd="160.160.128.160" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=http
2017-08-12T10:33:44.761403+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=671cfbb5-2dcc-4654-9476-8e5c3f4ede9f fwd="160.160.128.160" dyno=web.1 connect=1ms service=4ms status=304 bytes=152 protocol=https
2017-08-12T10:33:45.049112+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=66af43f9-704b-4d36-85e1-c421d7b82db5 fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=304 bytes=238 protocol=https
2017-08-12T10:33:45.537451+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=4a018af5-c2ad-4b7b-a92e-c5f19ac70a1d fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=304 bytes=237 protocol=https
2017-08-12T10:33:49.013666+00:00 heroku[router]: at=info method=GET path="/about" host=m-landscape.herokuapp.com request_id=b62edcb0-df94-4bd5-88b7-27b2a7616f86 fwd="160.160.128.160" dyno=web.1 connect=1ms service=5ms status=304 bytes=151 protocol=https
2017-08-12T10:33:49.241580+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=522e5742-aaf5-46ce-a793-25a02551530d fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=304 bytes=238 protocol=https
2017-08-12T10:33:49.392113+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=5e55ed09-7177-408c-b150-bce9df17055e fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=304 bytes=237 protocol=https
2017-08-12T10:33:53.489863+00:00 heroku[router]: at=info method=GET path="/contact" host=m-landscape.herokuapp.com request_id=64b4440b-2c71-463c-b9f0-35f9883b2c52 fwd="160.160.128.160" dyno=web.1 connect=1ms service=7ms status=304 bytes=152 protocol=https
2017-08-12T10:33:53.710792+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=55282896-9e14-44a6-bd60-238b4bf13130 fwd="160.160.128.160" dyno=web.1 connect=1ms service=4ms status=304 bytes=238 protocol=https
2017-08-12T10:33:53.880755+00:00 heroku[router]: at=info method=GET path="/stylesheets/carousel.js" host=m-landscape.herokuapp.com request_id=9851b705-495e-4e19-aff9-fd0e2a12f925 fwd="160.160.128.160" dyno=web.1 connect=1ms service=4ms status=304 bytes=237 protocol=https
2017-08-12T10:33:54.017119+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=2ead8f6f-c527-4efb-b493-f2c36b87339b fwd="160.160.128.160" dyno=web.1 connect=1ms service=3ms status=304 bytes=237 protocol=https
2017-08-12T10:33:55.992789+00:00 heroku[router]: at=info method=GET path="/landscapes" host=m-landscape.herokuapp.com request_id=203e9a69-acdf-462f-9f15-cd1089d32911 fwd="160.160.128.160" dyno=web.1 connect=1ms service=5ms status=304 bytes=152 protocol=https
2017-08-12T10:33:56.162198+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.css" host=m-landscape.herokuapp.com request_id=01ed69ca-a1ba-4b86-bfd4-3178ff5860e7 fwd="160.160.128.160" dyno=web.1 connect=1ms service=3ms status=304 bytes=238 protocol=https
2017-08-12T10:33:56.190157+00:00 heroku[router]: at=info method=GET path="/stylesheets/main.js" host=m-landscape.herokuapp.com request_id=7d17deb9-8c7e-471f-b84a-3854ed944628 fwd="160.160.128.160" dyno=web.1 connect=1ms service=2ms status=304 bytes=237 protocol=https
This is my app.js code:
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
methodOverride = require("method-override"),
Landscape = require("./models/landscape"),
seedDB = require("./seeds"),
mongoose = require("mongoose");
mongoose.Promise = global.Promise;
mongoose.connect("mongodb://localhost/m_landscape", {useMongoClient: true});
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({extended: true}));
// Use method-override (We tell it what to look for(_method))
app.use(methodOverride("_method"));
// tell express to serve the public directory
app.use(express.static(__dirname + "/public"));
seedDB();
// ======
// ROUTES
// ======
app.get("/", function(req, res){
res.render("landing");
});
app.get("/landscapes", function(req, res){
res.render("landscapes");
});
app.get("/about", function(req, res){
res.render("about");
});
app.get("/gallery", function(req, res){
// Get all landscapes from DB
Landscape.find({},function(err, allLandscapes){
if(err){
console.log(err);
} else{
res.render("gallery", {landscapes: allLandscapes});
}
});
});
app.get("/gallery/:id", function(req, res){
// Find the campground with provided id
Landscape.findById(req.params.id, function(err, foundLandscape){
if(err){
console.log(err);
} else{
console.log(foundLandscape);
// Render show template with that landscape
res.render("show", {landscape: foundLandscape});
}
});
});
app.get("/contact", function(req, res){
res.render("contact");
});
app.listen(process.env.PORT, process.env.IP, function(){
console.log("Server Has started!");
});
........................................................................................................................................................................................................................................
You should resolve your MongoDB connection issue:
2017-08-12T06:38:56.820635+00:00 app[web.1]: (node:17)
UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): MongoError: failed to connect to server
[localhost:27017] on first connect [MongoError: connect ECONNREFUSED
127.0.0.1:27017]
You need return response to client,, if MongoDB return error:
app.get("/gallery", function(req, res){
// Get all landscapes from DB
Landscape.find({},function(err, allLandscapes){
if(err){
res.status(500).send({ error: err }); //added
console.log(err);
} else{
res.render("gallery", {landscapes: allLandscapes});
}
});
});
app.get("/gallery/:id", function(req, res){
// Find the campground with provided id
Landscape.findById(req.params.id, function(err, foundLandscape){
if(err){
res.status(500).send({ error: err }); //added
console.log(err);
} else{
console.log(foundLandscape);
// Render show template with that landscape
res.render("show", {landscape: foundLandscape});
}
});
});

Resources