0

My app uses port 80, but heroku does not let my app access port 80. So, I used 3000 and ran it.

However, now, I cannot access it because port 3000 is not accessible in heroku. How can my app gain access to heroku?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Does this answer your question? [How to make the webpack dev server run on port 80 and on 0.0.0.0 to make it publicly accessible?](https://stackoverflow.com/questions/33272967/how-to-make-the-webpack-dev-server-run-on-port-80-and-on-0-0-0-0-to-make-it-publ) – Osama Rizwan Jan 04 '21 at 05:15

2 Answers2

1

First of all, I think this is a misunderstanding regarding ports. Your app will run behind the proxy (aka load balancer), so you don't actually need to specify use 80 port (and you can't). Heroku provides env variable PORT and you must use that port to start your application. Heroku proxy runs on 80 port (and 443, which supports SSL) and redirect all traffic to PORT port.

Your Node.js app is improperly configured to bind to a port other than the one provided by Heroku via the $PORT environment variable.

Example:

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Our app is running on port ${ PORT }`);
});

Ref: Why is my Node.js app crashing with an R10 error?

KiraLT
  • 2,385
  • 1
  • 24
  • 36
0

Simple answer is you can't.

Heroku doesn't allow you to assign listening ports to your web apps directly. Your web apps are self contained and they will be assigned a dynamic port by Heroku. The only way to access that is to use the default port (80).

ishandeveloper
  • 176
  • 1
  • 7