Deploying nodeJS to Heroku internal error - node.js

I am trying to upload NodeJS app to Heroku. Everything installs fine and when I run
heroku local
Then everything works as expected on a local host. But when I run
heroku ps:scale web=1
heroku open
Browser opens, and it is loading the page for like 2-3 minutes, or even more and then I receive Application error. I am new to web development so that any ideas will be helpful. Thanks!

Thanks to gnerkus I managed to figure that out.
In logs I found next error:
heroku Error R10 (Boot timeout) -> Web process failed to bind to $PORT
Heroku dynamically assigns port to app and I was doing it manually:
app.listen(4000, function () {
Instead i just need listen like this:
.listen(process.env.PORT || 5000)
Answer was here:
Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

Related

Heroku fails to host my Node.js App , I just see "Cannot Get /"

I have looked at similar questions and not been able to solve this problem with what I found. I initially followed a YouTube tutorial on how to deploy a Node.js App to Heroku. After trying and failing, I began troubleshooting and could not fix the problem.
I then followed the instructions on Heroku's website for deploying a Node.js application here: https://devcenter.heroku.com/articles/deploying-nodejs and I found I seem to have done all the steps correctly. I was just missing the node version in the package.json which I have now added.
Here is how I have connected my Node.js app:
image of Heroku application dashboard
And here is the connected Github repo: https://github.com/AmeenIzhac/food-and-flow-backend
You can see in the repo that my port is specified correctly:
const port = process.env.PORT || 4000;
I then tried running the app locally on the command line with:
heroku local web
and this worked as you can see my application running on port 5000:
App running locally on port 5000
However when I press "Open app" in Heroku, I just see this:
Heroku hosted app fails to get /
I feel like I have done everything correctly but it doesn't seem to work. Any help to get it working would be much appreciated.
You need a procfile. What is the heroku error in heroku logs --tail?

Our Heroku server port 443 is blocked

Our Heroku machine was automatically started and after that our APIs are not accessible, I checked the logs, it said: Relocating dyno to a new server, so something happened to the machine, the log shows the my node process is running, but the APIs via https or http are not accessible, when I run ss -tulw, it showed neither 443 nor 80 was listening, and I could not find a way on the machine to open the ports, on the heroku machine, I have not ways to change the bash_profile, or export PORT=443, since it is not allowed to start node process from inside the machine, I can only start our node process via re-deployment with "git push heroku master", the process.env.PORT shows different port each time my node process redeployed, our application has been totally inaccessible by our customers for two days now, and we created a ticket on heroku support center, but nobody has taken actions yet for two days, please help. Thanks!
You cannot open ports on a dyno. Dynos do not listen on 443 or 80.
Dyno is assigned a port by Heroku. You should bind to that port when application starts.
You should have a Procfile in your repo which starts application on correct port, for example:
web: npm run server -- --port $PORT
More info:
Setting the port for node.js server on Heroku
on procfile
restarting dynos

NodeJS app failed with "Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch"

I am getting error saying Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch when I try to start the app, I am pretty sure I've configured the app to use the $PORT env variable provided by Heroku, as I could see the line saying Server running on 38594 in the log, the port will change every time I restarted the dyno, I tried to login bash with heroku run bash and start the app from within there with node dist/bundle/index.js, and it works without any error, but I could still not open the app from browser, could someone help to point me to the right direction? cheers
Turns out HTTPure was trying to bind to localhost, while Heroku allows 0.0.0.0 instead of localhost. The most confusing part is the master branch of HTTPure is binding to 0.0.0.0 https://github.com/cprussin/purescript-httpure/blob/master/src/HTTPure/Server.purs#L84 while the released version I am using is binding to localhost, the fix is to use serve' with 0.0.0.0 to bind to the correct hostname

HEROKU Application Err - Application error An error occurred in the application and your page could not be served

I'm looking a solution for my stupid problems.
I use Heroku to deployed my application. After I linked to github,I got this error when open my application:
Application error An error occurred in the application and your page
could not be served. If you are the application owner, check your logs
for details. You can do this from the Heroku CLI with the command
heroku logs --tail
I tried to research the solution but nothing worked.
My config in app.js
port = process.env.PORT || config.__port_server,
app.listen(port)
thank you

How to configure lite-server port for heroku?

I am trying to deploy nodejs lite-server on Heroku. I am able to run the server fine locally, but fails on deployment with this error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
The basic problem is I am not sure how to allow Heroku to set the port. They do this dynamically (I only know how to do it statically). So I need to set an environmental variable so the server can set the correct port. How can I do this using lite-server?
This problem has been address for different server setups:
To configure http server port for Heroku
Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
To configure Express server port for Heroku
Heroku Node.js Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
So I had the same issue. I ended up adding a bs-config.js file.
module.exports = {
port: process.env.PORT,
files: ['./**/*.{html,htm,css,js}'],
server:{
baseDir: "./"
}
};
Apparently Heroku dynamically assigns a new port each time it's started. So the port can't be hard coded.
How do I run Angular.JS 2 for TypeScript on C9.io on port 8080?

Resources