Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

651
Views
Heroku is giving me a 503 when trying to open my web app, works on local host

I am trying to deploy to heroku but get a 503 even though it runs on localhost. I am curious as to if my server is set up correctly as I am newer to programming. I hope anyone can point me in the correct direction as to where to look or provide a suggestion as I have spent countless hours on google to this point spanning a couple of weeks.

My main question is if I have set up my server correctly? I am not sure my listener will work for heroku and my .get are used for debugging on localhost when it was initially set up.

Also my full project is available here:

https://github.com/dirkdir/DerekDevSite

var express = require('express');
var app = express();
var path = require('path');


app.use(express.static(path.join(__dirname, 'public')));


app.get('/json', function(req, res) {
    console.log("GET the json");
    res
        .status(200)
        .json( {"jsonData" : true} );
});

app.get('/file', function(req, res) {
    console.log("GET the file");
    res
        .status(200)
        .sendFile(path.join(__dirname, 'app.js'));
});



    var server = app.listen(process.env.PORT || 5000), function() {
        var port = server.address().port;
        console.log("Express is working on port " + port);
});

Logs:

2017-04-24T20:04:43.755866+00:00 app[web.1]: at Module._compile (module.js:542:28) 2017-04-24T20:04:43.755867+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10) 2017-04-24T20:04:43.755868+00:00 app[web.1]: at Module.load (module.js:487:32) 2017-04-24T20:04:43.755868+00:00 app[web.1]: at tryModuleLoad (module.js:446:12) 2017-04-24T20:04:43.755869+00:00 app[web.1]: at Function.Module._load (module.js:438:3) 2017-04-24T20:04:43.755869+00:00 app[web.1]: at Module.runMain (module.js:604:10) 2017-04-24T20:04:43.755870+00:00 app[web.1]: at run (bootstrap_node.js:393:7) 2017-04-24T20:04:43.755871+00:00 app[web.1]: at startup (bootstrap_node.js:150:9) 2017-04-24T20:04:43.846556+00:00 heroku[web.1]: State changed from starting to crashed 2017-04-24T20:26:31.826133+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=derekdyerdev.herokuapp.com request_id=609ef253-0a56-41ac-b877-1fb242f6f4e1 fwd="69.36.89.218" dyno= connect= service= status=503 bytes= protocol=https 2017-04-24T20:26:32.319732+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=derekdyerdev.herokuapp.com request_id=f2a34e62-9765-

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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 :)

about 4 years ago · Santiago Trujillo Report

0

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

about 4 years ago · Santiago Trujillo Report

0

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;
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!