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!
Asked
Active
Viewed 510 times
1 Answers
2
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:

Anastazy
- 4,624
- 2
- 13
- 22
-
Thanks for your answer, my website has been accessible for over a year before the "relocating dyno to a new server" happened two days ago, the code is as follows: var port = normalizePort(process.env.PORT || '3100'); app.set('port', port); var server = http.createServer(app); server.listen(port); server.on('listening', onListening); My procfile just one line: web: DEBUG=./:* npm start Since it is not working anymore, so I tried to set the config vars, changed Procfile to web: DEBUG=./:* npm start -- --port $PORT or use 443 or 80, but nothing worked. So any clues? Thanks – idoor May 25 '21 at 04:41
-
"You should have a Procfile in your repo which starts application on correct port" So what is the correct port or where to set it? when I log console.debug('Env process.env.PORT: ', process.env.PORT); it prints out arbitrary port, why after the dyno is relocated to a new server, my website suddenly became inaccessible? I did not change any code and did not touch the server, then suddenly not accessible. Thanks very much for your help! – idoor May 25 '21 at 04:52
-
also when my website worked the past year, I used https with defaut 443 to access, it worked perfectly, now the same url does not work anymore and I did not even touch the server nor redeploy, and only found the log message: "relocating dyno to a new server", it is weird, It seems I do not have full control of the machine with a paid plan, so far no support from the company with my ticket. – idoor May 25 '21 at 05:04
-
Again: you don't set the ports. "Arbitrary" port which you see in the logs is the one you bind to by using `process.env.PORT` in your app. That is it. Heroku router listens on 443 and routes requests to your app on this "arbitrary" port. If your app is not visible from the network then maybe it is entirely another issue. Have you tried to access your app from different DNS? Do requests get to Heroku router? – Anastazy May 25 '21 at 06:53
-
We tried our domain url assigned by heroku from different machines of different wifi network, alway got "There's nothing here, yet" message, when monitoring on the log: heroku logs --tail, no log message printed, so how do I test to see if our requests get to Heroku router? this is the log message after it is deployed: Env process.env.PORT: 40995 2021-05-25T04:33:00.187082+00:00 app[web.1]: Listening on PORT: 40995 2021-05-25T04:33:00.525761+00:00 heroku[web.1]: State changed from starting to up. I printed out the process.env.PORT. – idoor May 25 '21 at 13:58
-
By the way I used command: nc -vz
443, it says connection to port 443 [tcp/https] succeeded! but I can not access my website, so what could be the issue? the same code worked before their migration of dyno to a new server. – idoor May 25 '21 at 14:50 -
This means request sucessfully reached Heroku network. However it looks like the request is not being routed to your app. Check if your domain is configured with correct `CNAME` records (DO NOT use `A` records). Also [look here](https://help.heroku.com/VKRNVVF5/what-is-the-correct-dns-cname-target-for-my-custom-domains), maybe it helps. – Anastazy May 27 '21 at 12:41
-
1You are right, the support said their router had an issue, it is now resolved. Thanks very much for your help. – idoor May 30 '21 at 01:15