I have a very simple, straight-forward node.js app [1] I want to deploy on heroku. Although I'm able to deploy it, the page can't be accessed in the browser.
I followed the advices from the 'Getting Started with Node.js on Heroku' guide [2]. When I run the application using node index.js
locally, I'm able to access the application at http://localhost:8080/index.jade
, however, when I try to access it on heroku at http://immonow.herokuapp.com:8080/index.jade
it would throw me a ERR_CONNECTION_REFUSED
HTTP error code.
How I deployed my app:
git commit -am "made changes"
// commit changesgit push origin master
// push to githeroku create
// create heroku appgit push heroku master
// push to herokuheroku ps:scale web=1
// start workers
My node.js server:
#!/usr/bin/env node
var http = require('http')
, jade = require('jade')
, static = require('node-static')
, jadeRe = /\.jade$/
, path = process.argv.slice(2)[0]
, fileServer = new static.Server(path || '.')
http.createServer(function (req, res) {
if (req.url.match(jadeRe)) {
res.writeHead(200, {'Content-Type': 'text/html'})
res.end(jade.renderFile('.' + req.url, {
filename: '.' + req.url.replace(jadeRe, '')
}))
} else {
req.addListener('end', function () {
fileServer.serve(req, res)
}).resume()
}
}).listen(8080)
Any help would be appreciated.
[1] https://github.com/takahser/immonow
[2] https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction