MERN app on Heroku - node.js

I'm trying to get mern app working on heroku. But right now even fixing of node server would be enough.
This is what i have already done.
Created app in heroku and push my project to it.
Added mLab database link. (running properly on local server)
put dev dependencies on the dependencies.
Tried running "heroku run node server.js" through heroku CLI. Then it logs as server started on port 8080.
But I cannot access the API or the web interface.
My app url = http://travelaround.herokuapp.com
Please note my web application was create using create-react-app
My Logs at heroku,
2017-05-14T17:17:50.113754+00:00 heroku[api.1]: Process exited with status 0
2017-05-14T17:17:52.979224+00:00 heroku[api.1]: Starting process with command `nodemon server.js`
2017-05-14T17:17:53.538796+00:00 heroku[api.1]: State changed from starting to up
2017-05-14T17:17:55.154398+00:00 app[api.1]: [33m[nodemon] 1.11.0[39m
2017-05-14T17:17:55.156364+00:00 app[api.1]: [33m[nodemon] to restart at any time, enter `rs`[39m
2017-05-14T17:17:55.156522+00:00 app[api.1]: [33m[nodemon] watching: *.*[39m
2017-05-14T17:17:55.157062+00:00 app[api.1]: [32m[nodemon] starting `node server.js`[39m
2017-05-14T17:17:55.982045+00:00 app[api.1]: Database connection Established at mongodb://test:asd123#ds139791.mlab.com:39791/travelaround
2017-05-14T17:17:56.008148+00:00 app[api.1]: api running on port 3000
2017-05-15T14:22:19.692618+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=travelaround.herokuapp.com request_id=b46a031e-db9d-4cac-93fa-ffd73f51e5f3 fwd="93.65.70.107" dyno= connect= service= status=503 bytes= protocol=http
2017-05-15T14:22:20.297803+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=travelaround.herokuapp.com request_id=9ca4977c-b45e-4f3e-b98a-1034855e8c4f fwd="93.65.70.107" dyno= connect= service= status=503 bytes= protocol=http

Ok, so from the screenshot of your Heroku dashboard and error, it looks like your dynos are not running. I suggest you compile all of your react code, so you only have static content on your frontend, and then turn on the API dyno, so you can actually curl to it from your react code.

Related

Heroku, Stopping all processes with SIGTERM, Process exited with status 143

My backend was hosted on heroku for more than a month and was working fine. Now, today when i opened my website it shows this error in heroku logs.
heroku logs
`` 2022-11-26T13:59:37.770793+00:00 heroku[web.1]: Unidling 2022-11-26T13:59:37.773849+00:00
` 2022-11-26T13:59:37.770793+00:00 heroku[web.1]: Unidling 2022-11-26T13:59:37.773849+00:00 heroku[web.1]: State changed from down to starting 2022-11-26T13:`your text`59:40.671794+00:00 heroku[web.1]: Starting process with command `npm start` `2022-11-26T13:59:43.453482+00:00 app\[web.1\]:\`
2022-11-26T13:59:43.453508+00:00 app\[web.1\]: \> server#1.0.0 start
2022-11-26T13:59:43.453508+00:00 app\[web.1\]: \> node index.js
2022-11-26T13:59:43.453509+00:00 app\[web.1\]:
2022-11-26T13:59:43.936570+00:00 app\[web.1\]: Server started successfully on port 28406
2022-11-26T13:59:44.394629+00:00 heroku\[web.1\]: State changed from starting to up
2022-11-26T13:59:45.969634+00:00 app\[web.1\]: MongoDB Connected: ac-rbrrtx1-shard-00-02.hnnmtja.mongodb.net
2022-11-26T13:59:47.331529+00:00 heroku\[router\]: at=info method=GET path="/todos" host=to-do.herokuapp.com request_id=498c9348-ac27-4d03-98c5-ed9650e5b6d3 fwd="74.125.215.152" dyno=web.1 connect=0ms service=2501ms status=200 bytes=770 protocol=https
2022-11-26T14:35:38.862987+00:00 heroku\[web.1\]: Idling
2022-11-26T14:35:38.864646+00:00 heroku\[web.1\]: State changed from up to down
2022-11-26T14:35:39.633081+00:00 heroku\[web.1\]: Stopping all processes with SIGTERM
2022-11-26T14:35:39.834323+00:00 heroku\[web.1\]: Process exited with status 143
2022-12-02T12:31:11.037127+00:00 app\[api\]: Scaled to web#0:Eco by user api-maintenance#heroku.com
2022-12-08T18:34:07.067959+00:00 heroku\[router\]: at=error code=H14 desc="No web processes running" method=GET path="/robots.txt" host=to-do.herokuapp.com request_id=c7c564c9-6334-4140-bf27-6b0750093c26 fwd="5.255.253.147" dyno= connect= service= status=503 bytes= protocol=https\`\`
`
First, I would like to confirm whether you are using free plan of Heroku or not. Because Heroku stopped its free plan starting from November-26-2022.
For further information:
https://make.wordpress.org/plugins/2022/09/13/heroku-free-tier-being-retired/
If you have a paid version then it's a problem associated with dynos as the error is giving code H14 (last line). This is most likely the result of scaling your web dynos down to 0 dynos. Scale up your dynos to fix it.
For more information visit Heroku error codes:
Heroku error codes

What is the reason behind error h14 "No web processes running" and Application error?

I made this project and deployed it on Heroku successfully and it was working, I checked it again two months and it was working properly, but today when I tried to open the website link it says Application error.
Logs are as follows:
2022-12-06T08:17:30.897980+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=limitless-shelf-83830.herokuapp.com request_id=d0c862ec-c21d-4e94-94e5-f6fed3d71af6 fwd="103.141.116.193" dyno= connect= service= status=503 bytes= protocol=https
2022-12-06T08:17:31.345120+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=limitless-shelf-83830.herokuapp.com request_id=a98c5850-0aa3-413d-94d9-4480a218ec3d fwd="103.141.116.193" dyno= connect= service= status=503 bytes= protocol=https
Is this issue from my side or heroku servers are down? What is the cause of this error and what are possible solutions?
I tried running
heroku ps:scale web=1
but it had no use.
Edit: I found the issue, Heroku has stopped offering free plans from 28th Nov 2022, and I deployed it free server.
As you mentioned, Heroku no longer provides free dyno plans.
Although if you have previously deployed apps, you can still access them after subscribing to one of their plans. If you are still experiencing an H14 error, try to reconfigure your dyno. Just change your dyno type to the subscribed plan and make sure you have toggle the selected dyno to the right in order to enable it.

heroku Nodejs app not unidling after request

I have a nodejs app that runs on heroku and works fine until it idles(because im on the free plan). After it idles when I try to wake the app up it logs: "App Crashed". This issue is fixed by restarting the app using the cli: heroku restart. However this is not a working solution for the end user. I am using deploy through github and webpack, which I mention because those are the only differences from my other heroku apps which unidle just fine. Is there a way to have the request unidle the app?
Here are the logs:
2022-06-30T17:13:21.294071+00:00 heroku[web.1]: Idling
2022-06-30T17:13:21.308560+00:00 heroku[web.1]: State changed from up to down
2022-06-30T17:13:22.877570+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2022-06-30T17:13:23.113129+00:00 heroku[web.1]: Process exited with status 143
2022-07-02T17:42:20.649030+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fwpsg.herokuapp.com request_id=1f058e06-12e9-4210-a9bc-097ebdce811d fwd="73.247.37.113"
dyno= connect= service= status=503 bytes= protocol=https

Heroku Discord Bot is offline

I'm hosting a discord chat bot on heroku, and suddenly it went offline. I am new to hosting on heroku, so i don't understand a lot, but, i tried simple things like deploying a branch again (im connected to github), and that wouldn't work.
Edit:
Here is the log:
Before i click open app:
2018-07-23T16:54:27.265702+00:00 app[worker.1]: at Function.Module._load (module.js:497:3)
2018-07-23T16:54:27.265704+00:00 app[worker.1]: at Function.Module.runMain (module.js:693:10)
2018-07-23T16:54:27.265705+00:00 app[worker.1]: at startup (bootstrap_node.js:191:16)
2018-07-23T16:54:27.265707+00:00 app[worker.1]: at bootstrap_node.js:612:3
2018-07-23T16:54:27.327613+00:00 heroku[worker.1]: State changed from up to crashed
2018-07-23T16:54:27.310511+00:00 heroku[worker.1]: Process exited with status 1
After clicking Open App:
2018-07-23T16:58:44.866697+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cratefield.herokuapp.com request_id=b32a5f7d-157e-45a5-805b-8c306140d020 fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https
2018-07-23T16:58:45.502353+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cratefield.herokuapp.com request_id=19e6fc48-37ed-48db-87f9-759d704ddb3e fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https
2018-07-23T16:58:45.552383+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=cratefield.herokuapp.com request_id=bba2456f-50bc-4dbb-bee2-50b36a8caef5 fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https
2018-07-23T17:01:47.069331+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=cratefield.herokuapp.com request_id=9a098d43-bc46-403a-9ed3-5b701cd720ac fwd="73.23.238.216" dyno= connect= service= status=503 bytes= protocol=https
That happens because you're using a web dyno: a dyno that is put asleep if the application doesn't serve a website for more than 1 hour.
The solution is to switch from a web dyno to a worker dyno: this type does not serve websites (and if you're running a Discord bot you don't need it) and never goes to sleep.
Go in your Procfile file & replace web with worker, it should look like this:
worker: npm start //this is the command you use to start your app.
If you want you can take a look at the Heroku article about sleeping apps.
I know it's one year late but for those who are still having this issue, you have a limit of 550 hours per month (about 22 days) to host your bot with the free plan (paid plans get no run time limit)
This might be the problem, you can check your notifications on heroku to find out.
The problem with your bot is that Heroku's free plan makes your application to sleep after 30 minutes of inactivity. The solution would be to select a paid plan to be sure that your bot remains active at all times.

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.

Resources