Heroku is giving me a 503 when trying to open my web app, works on local host
I had a similar issue. Worked on localhost.. not when deployed to Heroku. My problem? I had cloned a project (node_modules too) and my package.json did not have express, minimist etc.. so it obviously failed.
Tip: When deploying, view the logs right away so you can see what's happening throughout the deployment process. Viewing the logs after it has failed will only show you the end of the logs...
Lastly, ensure you listen on the proper port. I do this (as others do too)
var serverPort = 8080;
. . .
var port = process.env.PORT || serverPort;
You have the bracket on line 34
of your app.js
file in the wrong place.
Since the function is a callback, it needs to be within the params.
Change that last block to this:
const server = app.listen(process.env.PORT || 5000, () => {
const port = server.address().port;
console.log(`Express is working on port ${port}`);
});
I also modified the Procfile
to just this:
web: node app.js
After I modified that I was able to run locally, and I deployed it to my Heroku just to test, and it works fine :)
This may be helpful to someone. My initial Profile content was this :
web : node server.js
and after changing it to this, it worked :
web:node server.js
The space between 'web' and ':' symbol was the problem. Weird though