Our Heroku server port 443 is blocked - node.js

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

Related

Running Logux on Google Cloud Run doesn't find the running port

While trying to get Logux running in Cloud Run, I get this error:
Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.
Even though the server is running an the Dockerfile is exposing the correct port (which is mapped in Cloud run as well).
The Dockerfile is located here: https://github.com/knownasilya/battle-chess/blob/main/Dockerfile
Note that the server runs https and ws on port 31337.
As mentioned by the Cloud Run Troubleshooting docs, if we get the message:
Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.
And we know our code/container is working as expected, we should check that the port that that Cloud Run will be checking correlates with the one used in our app and like in this case, that the container listens on 0.0.0.0 (all the net interfaces)
As well this is mentioned in the Cloud Run Requirements doc:
The container must listen for requests on 0.0.0.0 on the port to which requests are sent. By default, requests are sent to 8080, but you can configure Cloud Run to send requests to the port of your choice. Cloud Run injects the PORT environment variable into the container. Inside Cloud Run container instances, the value of the PORT environment variable always reflects the port to which requests are sent. It defaults to 8080.

Access NodeJS server installed on Linux server

I created my App from this boilerplate
https://github.com/Bikranshu/express-react-boilerplate
Now I uploaded it to a live Linux server and Node server is running.
Screenshot of running server
But I am unable to access it through Browser with IP address of server.
http://ip_address:3000
After waiting long in browser it is showing timeout error.
Please guide me how can I access the node/react app from browser.
Server running at <ipaddress> is a local IP, are you in a different network than the server? If so, you should be typing https://<public ipaddress>:3000
UPDATE
Hosting services usually only forward port 80 (http) or 443 (https.) This means that your port 3000 is not allowed for public access. To fix your problem you need to change the listening port.
Check line 42 on
server/app.js change 'port' to "80" or check package.json and edit npm start to set port to 80

App not starting with pm2 after stopping execution

I have an app set to listen to port 66.
First I tried to run it with sudo node myapp.js . I was able to access it at the correct url (ip:66). Then I stopped the app (Ctrl+c) and started it with pm2, sudo pm2 start app.js. The status is online. However, that same url is now inaccessible.
Running sudo pm2 logs while the app is started with pm2 gives me the error EACCESS for port 66. No one else is running the app, and I am sure I am only using one console and killing the node service before starting it with pm2.
Pm2 was installed globally. Server is Debian stretch. Nodejs version is 8.x
I am logging as a normal user and using sudo to run the app.
on linux systems normal users are not allowed to listen to ports below 1024. There are several ways around this.
You can change this rule to allow non root users to open such ports. But this is a security risc and is not recommended. So i won't add a link to this solution.
you can also listen to a port that is greater than 1024 and then use a forward rule in your firewall to route port 66 to the port you opened.
https://www.systutorials.com/816/port-forwarding-using-iptables/
my (and pm2's) prefered solution is to listen to a port greater than 1024 and use a reverse proxy like nginx to route apps running on that server.
http://pm2.keymetrics.io/docs/tutorials/pm2-nginx-production-setup

Running node app digitalocean and accessing it

Im running my node app with grunt on a DO droplet. I start the server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:3000
But when I navigate to my dropletIP:3000 I cannot see the app, I get:
This site can’t be reached
mydropletIP refused to connect.
Shouldn't my app be available? I don't have nginx or anything installed.
I was having similar problem but the solution was simple. Change from 'localhost' to '0.0.0.0' i.e
.listen(8080, '0.0.0.0');
And then to test your api just enter your static ip of droplet with port that you have entered i.e droplet-ip:8080
Check the particular port is opened or not ,using following command
sudo ufw status
If any Firewall enabled and any port is block means you can see that.
netstat -an | grep "LISTEN " ( List of listening port on server)
I need this info ,then only we can find a problem

Heroku running a node module server

I am trying to create a node app that runs a module called noodlejs. This starts its own server running on port 8888 (on my local version). I have pushed the changes to heroku and no errors are caused. However how do I now access the noodlejs server on port 8888? Is this possible or does it need to run on another port?
Thanks!
I don't think you can run the app on port 8888 or any other port for that matter on Heroku. You can only choose between 80 or 443. And to do that, you use process.env.PORT environment variable that Heroku exposes.

Resources