Unable to deploy node app on heroku. Displays only welcome message - node.js

heroku logs
2018-04-20T20:45:50.151330+00:00 app[api]: Enable Logplex by user ghsklat2378123#gmail.com
2018-04-20T20:45:50.059558+00:00 app[api]: Release v1 created by user ghsklat2378123#gmail.com
2018-04-20T20:45:50.059558+00:00 app[api]: Initial release by user ghsklat2378123#gmail.com
2018-04-20T20:45:50.151330+00:00 app[api]: Release v2 created by user ghsklat2378123#gmail.com
2018-04-20T20:46:48.000000+00:00 app[api]: Build started by user ghsklat2378123#gmail.com
2018-04-20T20:46:58.098188+00:00 app[api]: Deploy 2b289e67 by user ghsklat2378123#gmail.com
2018-04-20T20:46:58.098188+00:00 app[api]: Release v3 created by user ghsklat2378123#gmail.com
2018-04-20T20:46:48.000000+00:00 app[api]: Build succeeded
2018-04-20T20:46:58.115335+00:00 app[api]: Scaled to web#1:Free by user ghsklat2378123#gmail.com
2018-04-20T20:47:00.895268+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-20T20:47:03.518908+00:00 app[web.1]:
2018-04-20T20:47:03.518933+00:00 app[web.1]: > node server.js
2018-04-20T20:47:03.518931+00:00 app[web.1]: > stywqrrd#1.0.0 start /app
2018-04-20T20:47:03.518935+00:00 app[web.1]:
2018-04-20T20:47:03.875652+00:00 app[web.1]: Express server listening on port 3000
2018-04-20T20:48:01.013365+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-04-20T20:48:01.013866+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-04-20T20:48:01.152301+00:00 heroku[web.1]: State changed from starting to crashed
2018-04-20T20:48:01.155261+00:00 heroku[web.1]: State changed from crashed to starting
2018-04-20T20:48:01.132422+00:00 heroku[web.1]: Process exited with status 137
2018-04-20T20:48:02.894892+00:00 heroku[web.1]: Starting process with command `npm start`
2018-04-20T20:48:05.106690+00:00 app[web.1]:
2018-04-20T20:48:05.106708+00:00 app[web.1]: > sstywqrrd#1.0.0 start /app
2018-04-20T20:48:05.106710+00:00 app[web.1]: > node server.js
2018-04-20T20:48:05.106712+00:00 app[web.1]:
2018-04-20T20:48:05.295340+00:00 app[web.1]: Express server listening on port 3000
This is a very simple node app that i'm unable to deploy. When I got the link it displays:heroku welcome to you new app. Refer to documentation if you need help deploying. Logs don't show any error(all logs shown in blue color). How do I solve this?
Cloned the repo and then did
git init, git add, git commit
heroku create
heroku git:remote -a safe-forest-59278
heroku apps:create myappName
git push heroku master

According to log statement
Error R10 (Boot timeout) -> Web process failed to bind to $PORT
within 60 seconds of launch
This simply means that the port your are trying to connect with is not available for some reason.
And most probably you're specifying the port like
port = 3000
You should change this line to
port = process.env.PORT || 3000
This will let heroku servers to assign an available port to your server to listen to.
Why this happens is because mostly the ports that you specify while developing an application, there are very rare chances for that ports to be available and open in production.

Related

How can deploy my MERN application on Heroku

I've just deployed my application MERN on Heroku and I used Clever-cloud to deploy my DB and I have a problem my application works for just a while about 5 - 10min after that I get an error H10.
2022-06-08T21:25:55.931817+00:00 heroku[web.1]: Process exited with status 1
2022-06-08T21:25:55.982112+00:00 heroku[web.1]: State changed from up to crashed

Heroku worker dyno not showing up even though it is added in Procfile

I am trying to set up Heroku to host my Discord bot. I am sure that I have set up my Procfile correctly, but the worker dyno doesn't show up under Resources. Only the web dyno shows up and that doesn't work as it crashes with error R10 immediately after startup. Can someone help?
Procfile
worker: node index.js
package.json
{
"name": "bot name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "author",
"license": "ISC",
"dependencies": {
"discord.js": "^12.2.0"
}
}
Log
2020-07-28T17:03:18.000000+00:00 app[api]: Build started by user
2020-07-28T17:03:42.000000+00:00 app[api]: Build succeeded
2020-07-28T16:58:24.618732+00:00 app[api]: Release v20 created by user
2020-07-28T16:58:24.897854+00:00 heroku[web.1]: State changed from crashed to starting
2020-07-28T16:58:27.754015+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-28T16:58:31.218171+00:00 app[web.1]:
2020-07-28T16:58:31.218205+00:00 app[web.1]: > bot#0.9.0 start /app
2020-07-28T16:58:31.218206+00:00 app[web.1]: > node index.js
2020-07-28T16:58:31.218206+00:00 app[web.1]:
2020-07-28T16:58:32.169174+00:00 app[web.1]: LOG> bot is now online!
2020-07-28T16:58:35.000000+00:00 app[api]: Build started by user
2020-07-28T16:58:58.755714+00:00 heroku[web.1]: State changed from starting to down
2020-07-28T16:58:58.660155+00:00 app[api]: Deploy 643b70ba by user
2020-07-28T16:58:58.660155+00:00 app[api]: Release v21 created by user
2020-07-28T16:58:59.000000+00:00 app[api]: Build succeeded
2020-07-28T16:59:28.079035+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-07-28T16:59:28.102556+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-07-28T16:59:28.220163+00:00 heroku[web.1]: Process exited with status 137
I deleted everything and set everything up again and it seems to work now. It's possible that it wasn't working because I didn't have the node_modules folder or because of some other error that happened in the first attempt of setting the bot up.
Go to your heroku app
Select Resources menu
Turn on the "worker: node index.js" and turn off the "web npm start"

Error R10 when deploying the API using AdonisJS on Heroku

Here is the error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Analyzing the log, I noticed that every time I 'run' the app on Heroku it directs to a different port.
I have already encountered numerous examples of how to solve this, but using Express and not explicitly using AdonisJS (which I am finding very limited).
Another issue I have is the use of the domain for my application, should the be the same as the Heroku provides or localhost (127.0.0.1)?
My log:
2019-03-28T12:54:19.688098+00:00 app[web.1]: info: serving app on http://127.0.0.1:48470
2019-03-28T12:55:17.075091+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-28T12:55:17.081028+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-28T12:55:16.883066+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-03-28T12:55:16.883174+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-03-28T12:55:17.056876+00:00 heroku[web.1]: Process exited with status 137
2019-03-28T12:55:20.176409+00:00 heroku[web.1]: Starting process with command `ENV_SILENT=true npm start`
2019-03-28T12:55:22.553527+00:00 app[web.1]:
2019-03-28T12:55:22.553548+00:00 app[web.1]: > adonis-api-app#4.1.0 start /app
2019-03-28T12:55:22.553551+00:00 app[web.1]: > node server.js
2019-03-28T12:55:22.553552+00:00 app[web.1]:
2019-03-28T12:55:23.598805+00:00 app[web.1]: info: serving app on http://127.0.0.1:37943
2019-03-28T12:56:20.763929+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-28T12:56:20.660053+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-03-28T12:56:20.660202+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-03-28T12:56:20.747895+00:00 heroku[web.1]: Process exited with status 137
2019-03-28T12:56:23.940320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=***** protocol=https
2019-03-28T13:21:40.085858+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-28T13:21:43.920685+00:00 heroku[web.1]: Starting process with command `ENV_SILENT=true npm start`
2019-03-28T13:21:46.419408+00:00 app[web.1]:
2019-03-28T13:21:46.419429+00:00 app[web.1]: > adonis-api-app#4.1.0 start /app
2019-03-28T13:21:46.419431+00:00 app[web.1]: > node server.js
2019-03-28T13:21:46.419433+00:00 app[web.1]:
2019-03-28T13:21:47.899057+00:00 app[web.1]: info: serving app on http://127.0.0.1:51104
My .env file:
HOST=127.0.0.1
PORT=8080
NODE_ENV=development
APP_NAME=AdonisJs
APP_URL=https://${HOST}:${PORT}
APP_KEY=*******
How to prevent the port from being changed?
There are a few things going on here.
Configuration from the environment
There are two main benefits to configuring your application from the environment:
It makes configuration environment-specific, e.g. so you can use different databases, mail servers, etc. in development from the ones you use in production
It lets you keep sensitive values like API keys and passwords out of your codebase
Including your .env file in your repository negates both of these benefits. It's fine to use one in development, and it can be a convenient way to set environment variables, but it shouldn't be committed to your repository or used in Heroku.
Heroku natively supports configuration from the environment. You can set variables in the web UI or via heroku:config on the command line. This is where your environment variables should go in production.
I strongly urge you to remove your .env file from your repository with
git rm --cached .env
add it to your .gitignore, and use Heroku's native environment-based configuration instead. You should also invalidate any API keys or passwords that are contained in that file and generate new ones.
For what it's worth, the AdonisJS documentation agrees with this approach:
The .env file should never be committed to your source control or shared with other people.
Different ports
This is entirely expected:
On Heroku, apps are completely self-contained and do not rely on runtime injection of a webserver into the execution environment to create a web-facing service. Each web process simply binds to a port, and listens for requests coming in on that port. The port to bind to is assigned by Heroku as the PORT environment variable.
Heroku tells you which port to bind to via the PORT environment variable, and you must use it. But this isn't the port that will be visible externally; the standard HTTP ports will be routed to your application automatically.
IP addresses
Your application should listen on all IP addresses. If you're using Express, I think that means you don't provide an IP address in your .listen() call. You should only provide the port there, and that port should come from the PORT environment variable.

Cloud code & push notifications may be unavailable

Here is an issue I am having with an app on Parse-Server (/Heroku).
I keep getting the message:
WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
Here is the complete log I have when running the command: git push heroku master
2018-02-2...+00:00 app[api]: Build started by user me#xyz.com
2018-02-2...+00:00 app[api]: Deploy bduxedc8 by user me#xyz.com
2018-02-2...+00:00 app[api]: Build succeeded
2018-02-2...+00:00 app[api]: Release v25 created by user me#xyz.com
2018-02-2...+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-02-2...+00:00 heroku[web.1]: Process exited with status 143
2018-02-2...+00:00 heroku[web.1]: Restarting
2018-02-2...+00:00 heroku[web.1]: State changed from up to starting
2018-02-2...+00:00 heroku[web.1]: Starting process with command `npm start`
2018-02-2...+00:00 app[web.1]:
2018-02-2...+00:00 app[web.1]: > parse-server-example#1.4.0 start /app
2018-02-2...+00:00 app[web.1]: > node index.js
2018-02-2...+00:00 app[web.1]:
2018-02-2...+00:00 app[web.1]: parse-server-example running on port 23377.
2018-02-2...+00:00 heroku[web.1]: State changed from starting to up
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
2018-02-28T04:03:21.595649+00:00 app[web.1]:
2018-02-28T04:03:21.595660+00:00 app[web.1]: WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
2018-02-28T04:03:21.595663+00:00 app[web.1]:
And if I change https to http in my configuration, I see exactly the same behavior.
Beside if I try to access to https://myapp.herokuapp.com/ in a browser I can do it with no problem.
I have read many post on the issue but nothing drove me to a solution.
That would be great if someone could let me know how to solve this.
I faced this issue and it might help someone in the future.
Note that this is one of the reasons why this warning might be thrown.
This is for parse server version: 2.8.2
To create your own standalone parse server, using express, the basic steps involved are close to:
Create a parse-server object with all your config like. For example: const api = new ParseServer(config);
config will contain the server URL along with all other requirements.
Create an express app object. For example: const app = express();
Then mount the parse server API on the express like -> app.use(mountPath, api);
And then create the server like: const httpServer = require('http').createServer(app);
And then start listening on a port like: httpServer.listen(port);
As soon as the mount is called, the parse-server will verify the url mentioned in the config by making a request to /health endpoint.
If for some reason there is a delay in listening to the port (point 6) after mounting the API (point 4), then the above warning will be thrown.
For example, in one case I was establishing a mongoose connection and only then started listening to the port. Because of this, the verification of URL from parse server failed, although everything worked fine after that.
And one of the possible solutions is to get done with all such work before mounting the parse API and ensuring no delay between mounting and listening to the port as described above.
While this may not be the exact steps for creating a parse server on heroku, the idea is that:
parse server will call verify url on the server url mentioned in the configs.
And if there is delay in starting the server after you have mouted the parse apis, the above warning will be thrown.
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
Notice status is 404, this doesn't exist, and the host says myapp.herokuapp.com
Do you perhaps have a server_url key set to literally myapp.heroku.com, or did you redact the name of your app?

Heroku Node.js - Web process failed to bind to $PORT

Deploying a node.js app on Heroku. Facing the below error.
Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
I don't have the PROC file in my app. The node.js app has started successfully. My code correctly uses process.env.PORT to bind.
2016-10-14T15:34:52.802582+00:00 app[web.1]: Rest service ready on port 22712
2016-10-14T15:34:52.983831+00:00 app[web.1]: Subscription result: {"success":true}
2016-10-14T15:34:52.864941+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-10-14T15:34:54.289684+00:00 heroku[web.1]: Process exited with status 143
2016-10-14T15:30:03.693688+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
Any help would be greatly appreciated

Resources