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

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

Related

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

Azure AppService, Container fails to start even though NextJS is up

I'm trying a simple NextJS server in an Azure AppService, and the container fails to start, even though the logs indicate that NextJS is up and ready to server files. The code works fine locally.
My code is here: https://github.com/CutieDarkFae/Catz
The container log finishes with:
***2020-06-11T08:43:19.032969810Z Extracting modules...
2020-06-11T08:43:44.262867136Z Done.
2020-06-11T08:43:45.328947365Z
2020-06-11T08:43:45.328985465Z > cats#0.1.0 start /home/site/wwwroot
2020-06-11T08:43:45.328992064Z > next start
2020-06-11T08:43:45.328996364Z
2020-06-11T08:43:47.016355156Z ready - started server on http://localhost:3000***
But the AppService logs end with:
2020-06-11T08:46:44.113Z INFO - Waiting for response to warmup request for container catz_0_39a9d511. Elapsed time = 210.9209243 sec
2020-06-11T08:46:59.249Z INFO - Waiting for response to warmup request for container catz_0_39a9d511. Elapsed time = 226.0570954 sec
2020-06-11T08:47:03.323Z ERROR - Container catz_0_39a9d511 for site catz did not start within expected time limit. Elapsed time = 230.1311154 sec
2020-06-11T08:47:03.326Z ERROR - Container catz_0_39a9d511 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-06-11T08:47:03.342Z INFO - Stopping site catz because it failed during startup.
How can I get the container to notice that the app is up and running? and not to time out?
Or is an AppService the wrong place to put a NextJS server?
It looks like your app is starting on port 3000 but the App Service is expecting it on port 8080.
Set the app setting WEBSITES_PORT to 3000. https://learn.microsoft.com/en-us/azure/app-service/containers/configure-custom-container
The suggestion here didn't work for me alas, it kept trying on 8080 no matter what :(
What did work is the approved answer here:
unable to deploy next js to azure
I would have preferred a much simpler solution though
As Silent mentioned. Kindly use app setting WEBSITES_PORT to set the port for your own docker image while for blessed images use PORT environment variable as the listening port.
In your application, please use the PORT or WEBSITES_PORT (as applicable) environment variable as the main web server’s listening port, instead of using a hardcoded port number ( on app start-up on locahost:3000). The PORT environment variable is automatically set by App Service platform at startup time.
As mentioned, you could try these ways:
Use the EXPOSE instruction in your Dockerfile to expose port 3000.
Use the WEBSITES_PORT app setting with a value of "3000" to expose that port.
If the issue still persist, just to isolate, you could change the script to - "/home/site/wwwroot/node_modules/next/dist/bin/next start" and change the change the port 80 and see if that helps.

I get a EADDRINUSE error when I try to start a node.js server on OpenShift

So, I successfully commited a node.js app to OpenShift - without getting any error - but it does not work (error 503 when trying to access it through my browser, connection timeout when running tests against it from my local machine). The output when commiting says that node and mysql start successfully, and that the build succeeded.
I accessed the server through ssh, and checked the node log. It says an EADDRINUSE occured: Error: listen EADDRINUSE :::8080.
In my configuration, I use:
"server":{
"host":"OPENSHIFT_NODEJS_IP",
"port":"OPENSHIFT_NODEJS_PORT"
}
I also checked available environement variables in the shell with export and both are there, and 8080 is the right port.
When running ps in the shell, it does show only the programs ps and bash running. EADDRINUSE should mean that the port is already in use by another program, but I don't see anything running... I can't run netstat (permission denied).
I tried various combinations of stop/start/restart, but I always get the same error.
I am pretty lost at this point. Any pointers would be appreciated!
I found the problem. Locally, I used to start the server with app.listen(port);, which is enough to run it and access it on localhost. But that does not work on OpenShift. The host needs to be specified too: app.listen(port, host);.

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?

Deploying nodeJS to Heroku internal error

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)

Resources