spaceDog spaceDog - 5 months ago 198
Node.js Question

node server not running - throwing process.nextTick(function() { throw err; })

I am trying to run node express in c9.io but I am having problem it gives me this error I can't figure it out. I am getting this error message.

$ node app.js
Server is running

/home/ubuntu/workspace/RESTful Routing/RESTfulBlogApp/node_modules/mongodb/lib/server.js:242
process.nextTick(function() { throw err; })
^
Error: getaddrinfo ENOTFOUND localhost.restful_blog_app localhost.restful_blog_app:27017
at errnoException (dns.js:27:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:26)

var bodyParser = require("body-parser"),
mongoose = require("mongoose"),
express = require("express"),
app = express();

mongoose.connect("mongodb://localhost.restful_blog_app");
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended: true}));

app.listen(process.env.PORT, process.env.IP, function(){
console.log("Server is running");
});

Answer

I think it's mongoose.connect("mongodb://localhost/restful_blog_app");