I am trying to deploy a painfully simple NodeJS app to Heroku.
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello World');
}).listen(3000);
I have tested it locally and run the following commands.
heroku login
heroku create marktyers
git push heroku master
heroku ps:scale web=1
The app seems to deploy but when I view the URL I get an Application Error.
https://marktyers.herokuapp.com
Here are the heroku logs.
node server.js
heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=marktyers.heroku
app.com request_id=d2ccf200-f034-4b62-951a-0a1d3055bf35 fwd="90.244.82.220" dyno= connect= service= status=503 bytes=
heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
heroku[web.1]: Stopping process with SIGKILL
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: Process exited with status 137
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=marktyers.herokuapp.com request_id=d63e046a-ec03-488b-930d-2ac05d006e56 fwd="90.244.82.220" dyno= connect= service= status=503 bytes=
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=marktyers.herokuapp.com request_id=21ba5a8b-2074-4798-8b40-ff0ea140bb1e fwd="90.244.82.220" dyno= connect= service= status=503 bytes=
The sample app provided by Heroku uses the Express package and so is of little use to help me understand the issue.
Here are the messages when pushing:
remote: node_modules cached: false
remote:
remote: NPM_CONFIG_PRODUCTION=true
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: Resolving node version (latest stable) via semver.io...
remote: Downloading and installing node 0.12.2...
remote: Using default npm version: 2.7.4
remote:
remote: -----> Building dependencies
remote: No cache available
remote: Installing node modules
remote: npm WARN package.json [email protected] No README data
remote:
remote: -----> Checking startup method
remote: No Procfile; Adding 'web: npm start' to new Procfile
remote:
remote: -----> Finalizing build
remote: Creating runtime environment
remote: Exporting binary paths
remote: Cleaning npm artifacts
remote: Cleaning previous cache
remote: Caching results for future builds
remote:
remote: -----> Build succeeded!
remote:
remote: [email protected] /tmp/build_a046b18bb77857c1547f983f14ba04b9
remote: └── (empty)
remote:
remote: WARNING: Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing... done, 9.1MB
remote: -----> Launching... done, v3
remote: https://marktyers.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/marktyers.git
* [new branch] master -> master
The issue is using a fixed port number. If I set the port to process.env.PORT the app deploys correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With