When defining the port variable, we give it 2 choices right? a number.. 5000 in my case, or process.env.PORT which is an env variable, since they are predefined, the app will always use them, instead of "0.0.0.0"
// Use PORT provided in environment or default to 3000
const port = process.env.PORT || 3000;
// Listen on `port` and 0.0.0.0
app.listen(port, "0.0.0.0", function () {
// ...
});
// Use PORT provided in environment or default to 3000
const port = process.env.PORT || 3000;
// Listen on `port` and 0.0.0.0
app.listen(port, "0.0.0.0", function () {
// ...
});
This is provided as the solution for this problem.. But my question is, if I update my code with app.listen(port, "0.0.0.0" ... ) shouldn't it automatically start on the port variable defined earlier?