Heroku problems: Error: failed to connect to [localhost:27017]
I've been following tyler's tutorial. Everything has been going well so far until heroku open, which I ran in my dist directory, containing:
lib package.json Procfile public server.js views
Here is the error message:
$ heroku open
Opening rocky-sands-9303... failed
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: Unable to find a browser command. If this is unexpected, Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at https://github.com/copiousfreetime/launchy/issues/new (Launchy::CommandNotFoundError)
Backtrace: /usr/local/heroku/vendor/gems/launchy-2.4.2/lib/launchy/applications/browser.rb:63:in `browser_cmdline'
/usr/local/heroku/vendor/gems/launchy-2.4.2/lib/launchy/applications/browser.rb:67:in `cmd_and_args'
/usr/local/heroku/vendor/gems/launchy-2.4.2/lib/launchy/applications/browser.rb:78:in `open'
/usr/local/heroku/vendor/gems/launchy-2.4.2/lib/launchy.rb:29:in `open'
/usr/local/heroku/lib/heroku/helpers.rb:328:in `block in launchy'
/usr/local/heroku/lib/heroku/helpers.rb:227:in `action'
/usr/local/heroku/lib/heroku/helpers.rb:326:in `launchy'
/usr/local/heroku/lib/heroku/command/apps.rb:338:in `open'
/usr/local/heroku/lib/heroku/command.rb:218:in `run'
/usr/local/heroku/lib/heroku/cli.rb:28:in `start'
/usr/local/heroku/bin/heroku:25:in `<main>'
Command: heroku open
Version: heroku-toolbelt/3.4.1 (x86_64-linux) ruby/1.9.3
Here are my heroku logs. I have two suspicions, though they both shouldn't be the case as heroku is hosting, instead of my machine.
-
It might be something to do with "failed to connect to [localhost:27017]", perhaps related to a localhost problem I've encountered before on my machine. If this is the case, how can I fix it?
-
It might have to do with the different ports Express server listens to. My machine only allows port numbers on its whitelist, so many of these server ports are not on the list (27017 is). If this is the case, how can I fix the Express server port number?
Express server listening on port 19273 in production mode ... Express server listening on port 57183 in production mode ... Express server listening on port 18306 in production mode ... Express server listening on port 37805 in production mode
The first error with heroku open is because launchy can't find your default browser, you'll need to check your system configuration (default browser, etc), or look at their docs https://github.com/copiousfreetime/launchy to see how to fix that.
Alternatively, you can just launch your browser manually and go to my-heroku-name.herokuapp.com
The other error you're getting is because you don't have a mongodb enabled on your heroku server. If you scaffold out the project with mongoose you will need to do heroku addons:add mongohq which will create a mongohq database, and set your process.env.MONGOHQ_URL to the new database.
The lib/config/env/production.js file looks for a few different environment variables to use for the mongoDB connection, and then defaults to a local mongodb database if all else fails:
mongo: {
uri: process.env.MONGOLAB_URI ||
process.env.MONGOHQ_URL ||
'mongodb://localhost/fullstack'
}