Application error message when trying to open heroku app - node.js

I'm new to nodejs and trying to deploy a simple word game to heroku. i followed the instruction on heroku website and everyting works until the last command "heroku open" and it opens a web browser with the following message:
"An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details."
The heroku logs shows:
2016-08-04T18:56:36.552635+00:00 heroku[api]: Enable Logplex by teamsky916#gmail .com
2016-08-04T18:56:36.552635+00:00 heroku[api]: Release v2 created by teamsky916#g mail.com
2016-08-04T18:58:34.328360+00:00 heroku[router]: at=info code=H81 desc="Blank ap p" method=GET path="/" host=build-word-game.herokuapp.com request_id=f238942c-ef aa-4011-b505-7e5f062221a3 fwd="107.77.75.83" dyno= connect= service= status=502 bytes=
2016-08-04T18:58:35.171645+00:00 heroku[router]: at=info code=H81 desc="Blank ap p" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_id= a02c27ef-865c-48e3-91cd-bd6e29ca51e3 fwd="107.77.75.83" dyno= connect= service= status=502 bytes=
2016-08-04T19:26:43.069903+00:00 heroku[api]: Scale to web=1 by teamsky916#gmail .com
2016-08-04T19:26:43.070467+00:00 heroku[api]: Deploy 4725c48 by teamsky916#gmail .com
2016-08-04T19:26:43.070552+00:00 heroku[api]: Release v3 created by teamsky916#g mail.com
2016-08-04T19:26:43.473784+00:00 heroku[slug-compiler]: Slug compilation finishe d
2016-08-04T19:26:43.473765+00:00 heroku[slug-compiler]: Slug compilation started
2016-08-04T19:26:45.915539+00:00 heroku[web.1]: Starting process with command `n ode server.js`
2016-08-04T19:26:50.481084+00:00 app[web.1]: listening to port 3000!
2016-08-04T19:27:46.488886+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-08-04T19:27:46.488886+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-08-04T19:27:46.631684+00:00 heroku[web.1]: Process exited with status 137
2016-08-04T19:27:46.618404+00:00 heroku[web.1]: State changed from starting to c rashed
2016-08-04T19:27:46.619564+00:00 heroku[web.1]: State changed from crashed to st arting
2016-08-04T19:27:48.599634+00:00 heroku[web.1]: Starting process with command `n ode server.js`
2016-08-04T19:27:51.304417+00:00 app[web.1]: listening to port 3000!
2016-08-04T19:28:48.755864+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-08-04T19:28:48.755938+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-08-04T19:28:48.879934+00:00 heroku[web.1]: Process exited with status 137
2016-08-04T19:28:48.893371+00:00 heroku[web.1]: State changed from starting to c rashed
2016-08-04T19:31:31.210359+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=e0536d30 -8590-453d-9a04-fb8a56eb6893 fwd="107.77.213.153" dyno= connect= service= status =503 bytes=
2016-08-04T19:31:32.552715+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_ id=89bfb417-9793-4687-b400-72cc34d16ea8 fwd="107.77.213.153" dyno= connect= serv ice= status=503 bytes=
2016-08-04T19:53:16.445270+00:00 heroku[web.1]: State changed from crashed to st arting
2016-08-04T19:53:18.025971+00:00 heroku[web.1]: Starting process with command `n ode server.js`
2016-08-04T19:53:19.981109+00:00 app[web.1]: listening to port 3000!
2016-08-04T19:54:18.509309+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-08-04T19:54:18.509204+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-08-04T19:54:18.601875+00:00 heroku[web.1]: Process exited with status 137
2016-08-04T19:54:18.606261+00:00 heroku[web.1]: State changed from starting to c rashed
2016-08-04T19:59:58.452903+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=450b80d9 -a366-4e0f-9426-ff89eac931fb fwd="107.77.213.153" dyno= connect= service= status =503 bytes=
2016-08-04T19:59:59.109794+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_ id=1eecc47a-5334-4a38-bd8d-093a9164ead5 fwd="107.77.213.153" dyno= connect= serv ice= status=503 bytes=
2016-08-04T20:01:28.744667+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/" host=build-word-game.herokuapp.com request_id=a2d52aea -d7fc-4f18-b023-50aa8e93587c fwd="107.77.213.153" dyno= connect= service= status =503 bytes=
2016-08-04T20:01:29.378063+00:00 heroku[router]: at=error code=H10 desc="App cra shed" method=GET path="/favicon.ico" host=build-word-game.herokuapp.com request_ id=8e62ab9c-50a3-43eb-9579-9c3d4a6c9d42 fwd="107.77.213.153" dyno= connect= serv ice= status=503 bytes=
I appreciate your help.

It looks like your Node application is not starting properly. This is likely due to you not binding your Node server to the correct port.
On Heroku, you must bind your Node server to a port number specified in the PORT environment variable. This is because Heroku magically handles routing for your requests, on a server with many other applications.
What you should do is modify your Node code so that it listens on port process.env.PORT.
Here's an example Express.js application that listens to the correct port, as an example:
var express = require('express');
var app = express();
app.listen(process.env.PORT);

Related

Heroku Build Successful but application error in React/Node app

I'm running a React.js/Node.js application on heroku. I have been successfully deploying for a while but after changing the code base yesterday The build is successful and I get an application error. Specigically what I changed in the code base was switching back from SASS to CSS na dadding OAuth to my nodemailer functionality.
I have checked all the environment variables and my port is set to process.env.PORT || 8080
2020-04-23T18:00:39.000000+00:00 app[api]: Build started by user mlisonek98#gmail.com
2020-04-23T18:01:29.044301+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-23T18:01:28.000000+00:00 app[api]: Build succeeded
2020-04-23T18:01:28.310226+00:00 app[api]: Release v109 created by user mlisonek98#gmail.com
2020-04-23T18:01:28.310226+00:00 app[api]: Deploy 8bb6c992 by user mlisonek98#gmail.com
2020-04-23T18:01:36.276828+00:00 app[web.1]:
2020-04-23T18:01:36.276853+00:00 app[web.1]: > badgrey#1.0.0 start /app
2020-04-23T18:01:36.276854+00:00 app[web.1]: > node server
2020-04-23T18:01:36.276854+00:00 app[web.1]:
2020-04-23T18:01:36.971835+00:00 app[web.1]:
2020-04-23T18:02:34.074965+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-23T18:02:35.428955+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=badgrey-dev.herokuapp.com request_id=a08398b4-fa84-4b9c-9365-af9a5f357652 fwd="108.46.200.18" dyno= connect= service= status=503 bytes= protocol=https
2020-04-23T18:02:35.774613+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=badgrey-dev.herokuapp.com request_id=d6bea10e-304f-4b1b-be04-33815ffb6c26 fwd="108.46.200.18" dyno= connect= service= status=503 bytes= protocol=https
2020-04-23T18:02:37.499473+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=badgrey-dev.herokuapp.com request_id=405f4943-a154-47d4-8bb5-0699597e8649 fwd="108.46.200.18" dyno= connect= service= status=503 bytes= protocol=https
I get an h10 error, and there is no other information. This application is running on the heroku free tier. Any suggestions as to why this is happeneing? I would be glad to upoad more code but I'm not sure what I would, especially since everything works locally.
It was the node version, Node released version 14 yesterday or something.

Cannot run my node app on Heroku. I attached the log [duplicate]

This question already has answers here:
Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
(38 answers)
Closed 2 years ago.
My node app worked fine when I hosted it in Glitch and DigitalOcean server.
But it doesn't work when I try in Heroku.
Here's the log I get after running heroku logs --tail:
› Warning: heroku update available from 7.35.0 to 7.39.5.
2020-04-24T18:56:56.066168+00:00 app[api]: Initial release by user
cuinjune#gmail.com 2020-04-24T18:56:56.167629+00:00 app[api]: Enable
Logplex by user cuinjune#gmail.com 2020-04-24T18:56:56.167629+00:00
app[api]: Release v2 created by user cuinjune#gmail.com
2020-04-24T18:56:56.066168+00:00 app[api]: Release v1 created by user
cuinjune#gmail.com 2020-04-24T18:57:07.000000+00:00 app[api]: Build
started by user cuinjune#gmail.com 2020-04-24T18:57:25.352788+00:00
app[api]: Deploy 1958e9f7 by user cuinjune#gmail.com
2020-04-24T18:57:25.370743+00:00 app[api]: Scaled to web#1:Free by
user cuinjune#gmail.com 2020-04-24T18:57:25.352788+00:00 app[api]:
Release v3 created by user cuinjune#gmail.com
2020-04-24T18:57:26.000000+00:00 app[api]: Build succeeded
2020-04-24T18:57:30.065364+00:00 app[web.1]:
2020-04-24T18:57:30.065389+00:00 app[web.1]: > battle-square#1.0.0
start /app 2020-04-24T18:57:30.065389+00:00 app[web.1]: > node
index.js 2020-04-24T18:57:30.065390+00:00 app[web.1]:
2020-04-24T18:57:30.206325+00:00 app[web.1]: Server is running
localhost on port: 3000 2020-04-24T18:58:28.351045+00:00
heroku[web.1]: State changed from starting to crashed
2020-04-24T18:58:28.354624+00:00 heroku[web.1]: State changed from
crashed to starting 2020-04-24T18:58:33.378248+00:00 app[web.1]:
2020-04-24T18:58:33.378282+00:00 app[web.1]: > battle-square#1.0.0
start /app 2020-04-24T18:58:33.378283+00:00 app[web.1]: > node
index.js 2020-04-24T18:58:33.378283+00:00 app[web.1]:
2020-04-24T18:58:33.576646+00:00 app[web.1]: Server is running
localhost on port: 3000 2020-04-24T18:58:52.316240+00:00
heroku[router]: at=error code=H20 desc="App boot timeout" method=GET
path="/" host=secure-eyrie-48591.herokuapp.com
request_id=6ee36c25-45d3-4e0a-aae0-c9ddc89e1b69 fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
2020-04-24T18:59:31.070175+00:00 heroku[web.1]: State changed from
starting to crashed 2020-04-24T18:59:38.566167+00:00 heroku[router]:
at=error code=H10 desc="App crashed" method=GET path="/"
host=secure-eyrie-48591.herokuapp.com
request_id=55127020-5b19-4154-885f-79287266284a fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
2020-04-24T18:59:39.185406+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/favicon.ico"
host=secure-eyrie-48591.herokuapp.com
request_id=0f99d119-de28-4e80-a22d-0dab655469f7 fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
2020-04-24T19:00:26.640037+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/"
host=secure-eyrie-48591.herokuapp.com
request_id=462f5dd6-c6ee-42d2-9251-50894d822936 fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
2020-04-24T19:00:27.065538+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/favicon.ico"
host=secure-eyrie-48591.herokuapp.com
request_id=5e8e1903-9520-4c1e-a468-aecb35ba453f fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
2020-04-24T19:06:10.144325+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/"
host=secure-eyrie-48591.herokuapp.com
request_id=ca404bc9-b117-42c9-82db-db08862572a8 fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
2020-04-24T19:06:10.679020+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/favicon.ico"
host=secure-eyrie-48591.herokuapp.com
request_id=c18910bc-34ad-4ae0-8d88-b1dfbfed00f9 fwd="69.116.190.29"
dyno= connect= service= status=503 bytes= protocol=https
And here's the link to my repo: https://github.com/cuinjune/battle-square
What's the problem and how to fix this?
The cause is in the logs: Server is running localhost on port: 3000.
The app is using port 3000, locally is fine but Heroku gives you a dynamic port upon deployment, therefore you need to bind to this port which is provided through the env variable $PORT

Error while deploying app(Nodejs + sqlite3) on Heroku

I am trying to deploy my app (Node.js) on Heroku which uses a sqlite3 database, deployment is done but while running the app I am getting the following error:
2020-04-23T10:07:50.747074+00:00 app[web.1]: App started on port 5000
2020-04-23T10:07:50.748081+00:00 app[web.1]: Connected to the SQLite database.
2020-04-23T10:07:50.748081+00:00 app[web.1]: Connected to the SQLite database.
2020-04-23T10:08:48.280947+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-23T10:08:52.004314+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=backendthemesdemo.herokuapp.com request_id=470f5cfb-58e4-4ab0-b666-14880d5c31a8 fwd="43.241.194.49" dyno= connect= service= status=503 bytes= protocol=https
2020-04-23T10:08:53.642688+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=backendthemesdemo.herokuapp.com request_id=f2d12092-9809-463b-89c1-eb5fcd8b267f fwd="43.241.194.49" dyno= connect= service= status=503 bytes= protocol=https
2020-04-23T10:30:38.831607+00:00 heroku[web.1]: State changed from crashed to starting

Heroku node.js Procfile for script not in root

My aim is to create a groupme bot using heroku and node.js https://github.com/whitec54/shouts-things
I'm pretty new to web development so maybe this is glaring but I can't seem to fix my heroku application error.
This is the message returned by the logs:
2016-07-26T01:44:52.756548+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-26T01:44:53.848661+00:00 heroku[web.1]: Starting process with command `node routes/index.js`
2016-07-26T01:44:55.966222+00:00 heroku[web.1]: Process exited with status 0
2016-07-26T01:45:09.474760+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=shouts-things.herokuapp.com request_id=19173085-e8ed-4a85-8cd9-90c96b7347f6 fwd="108.178.113.130" dyno= connect= service= status=503 bytes=
2016-07-26T01:45:08.701288+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shouts-things.herokuapp.com request_id=f29fef93-7530-4c1e-9724-73884694b457 fwd="108.178.113.130" dyno= connect= service= status=503 bytes=
this error is seems better than what I started with but I'm not sure where to go from here. In spite of the reading I've done my understanding of how Procfiles work in heroku is pretty weak.
In your Procfile it has mentioned to start routes/index.js which doesn't have any code to run the express server. You should be having this route registered on app.js and start app.js with node.
express-generator npm will help you get started with the basic scaffolding required for a nodejs project.

Application Error Found in Heroku

I have hosted my app first time in Heroku. it works on my localhost but when I hosted it on Heroku it gives Application error: An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details. i check my logs and logs are:
$ heroku logs --app peaceful-wildwood-9840
←[36m2014-06-08T18:48:05.660654+00:00 heroku[api]:←[0m Enable Logplex by aminayo
usuf_13#hotmail.com
←[36m2014-06-08T18:48:05.660736+00:00 heroku[api]:←[0m Release v2 created by ami
nayousuf_13#hotmail.com
←[33m2014-06-08T18:49:27+00:00 heroku[slug-compiler]:←[0m Slug compilation start
ed
←[36m2014-06-08T18:49:33.638541+00:00 heroku[api]:←[0m Deploy 2ab14e4 by aminayo
usuf_13#hotmail.com
←[36m2014-06-08T18:49:33.511107+00:00 heroku[api]:←[0m Scale to web=1 by aminayo
usuf_13#hotmail.com
←[36m2014-06-08T18:49:33.638621+00:00 heroku[api]:←[0m Release v3 created by ami
nayousuf_13#hotmail.com
←[33m2014-06-08T18:49:33+00:00 heroku[slug-compiler]:←[0m Slug compilation finis
hed
←[32m2014-06-08T18:49:36.203628+00:00 app[web.1]:←[0m Listening to Port : 3033..
.
←[32m2014-06-08T18:49:35.293036+00:00 heroku[web.1]:←[0m Starting process with c
ommand `node server.js`
←[32m2014-06-08T18:50:37.170068+00:00 heroku[web.1]:←[0m State changed from star
ting to crashed
←[32m2014-06-08T18:50:37.170632+00:00 heroku[web.1]:←[0m State changed from cras
hed to starting
←[32m2014-06-08T18:50:39.419734+00:00 app[web.1]:←[0m Listening to Port : 3033..
.
←[32m2014-06-08T18:50:35.901399+00:00 heroku[web.1]:←[0m Error R10 (Boot timeout )
-> Web process failed to bind to $PORT within 60 seconds of launch
←[32m2014-06-08T18:50:35.901708+00:00 heroku[web.1]:←[0m Stopping process with S
IGKILL
←[32m2014-06-08T18:50:37.165375+00:00 heroku[web.1]:←[0m Process exited with sta
tus 137
←[32m2014-06-08T18:50:38.558505+00:00 heroku[web.1]:←[0m Starting process with c
ommand `node server.js`
←[35m2014-06-08T18:51:20.593335+00:00 heroku[router]:←[0m at=error code=H20 desc
="App boot timeout" method=GET path=/ host=peaceful-wildwood-9840.herokuapp.com
request_id=aabed091-9c41-4639-9069-c02f8dd71503 fwd="39.48.218.219" dyno= connec
t= service= status=503 bytes=
←[35m2014-06-08T18:51:32.899300+00:00 heroku[router]:←[0m at=error code=H20 desc
="App boot timeout" method=GET path=/ host=peaceful-wildwood-9840.herokuapp.com
request_id=db181007-c7dd-47ba-a42f-91def32077df fwd="39.48.218.219" dyno= connec
t= service= status=503 bytes=
←[32m2014-06-08T18:51:39.895529+00:00 heroku[web.1]:←[0m State changed from star
ting to crashed
←[35m2014-06-08T18:51:40.797283+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path=/favicon.ico host=peaceful-wildwood-9840.herokuap
p.com request_id=e63e5ee2-b04e-4b13-8e61-77d1f4f4600b fwd="39.48.218.219" dyno=
connect= service= status=503 bytes=
←[35m2014-06-08T18:51:40.926423+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path=/ host=peaceful-wildwood-9840.herokuapp.com reque
st_id=88b77ad4-7547-4b41-b6c8-b820a38284b5 fwd="39.48.218.219" dyno= connect= se
rvice= status=503 bytes=
←[35m2014-06-08T18:51:42.930361+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path=/favicon.ico host=peaceful-wildwood-9840.herokuap
p.com request_id=010dcdf3-e68a-47bb-a821-6dd5613b14ce fwd="39.48.218.219" dyno=
connect= service= status=503 bytes =
←[32m2014-06-08T18:51:39.887550+00:00 heroku[web.1]:←[0m Process exited with sta
tus 137
←[32m2014-06-08T18:51:38.819255+00:00 heroku[web.1]:←[0m Error R10 (Boot timeout
) -> Web process failed to bind to $PORT within 60 seconds of launch
←[32m2014-06-08T18:51:38.819499+00:00 heroku[web.1]:←[0m Stopping process with S
IGKILL
←[35m2014-06-08T18:51:52.977231+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path=/favicon.ico host=peaceful-wildwood-9840.herokuap
p.com request_id=2ea71012-34e4-4361-9e04-9a1ae91716fa fwd="39.48.218.219" dyno=
connect= service= status=503 bytes=
←[35m2014-06-08T18:56:28.116367+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path=/ host=peaceful-wildwood-9840.herokuapp.com reque
st_id=597301b8-8be8-46f0-96a9-43bb5425395a fwd="39.48.218.219" dyno= connect= se
rvice= status=503 bytes=
The error, as shown above, is Error R10 (Boot timeout )
-> Web process failed to bind to $PORT within 60 seconds of launch. I can think of two things that can cause this:
Your startup is taking a long time - for example you're calling out to external web services while starting.
Or you're not listening to the right port, so as a result you'll never bind to the right port.
I'm guessing it's the second? What PORT number do you use? Do you do something like this?
var port = Number(process.env.PORT || 5000);

Resources