我的問題是關於mongo未連接到服務器? ,爲什麼它說無法連接到服務器[本地主機:27017]在第一次連接[MongoError:連接ECONNREFU SED 127.0.0.1:27017]MongoError:第一次連接時無法連接到服務器[localhost:27017] [MongoError:連接ECONNREFU SED 127.0.0.1:27017]
Here is my code:
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/BlogApp");
app.set("views engine", "ejs");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended: true}));
app.get('/', function (req, res) {
res.send('Hello World!')
});
app.listen(3000, function() {
console.log('Example app listening on port 3000!')
});
Mongod服務器是否正在運行?在瀏覽器中通過到達localhost:27017進行檢查。 –
嘗試''mongoose.connect('localhost:27017/BlogApp「); // 27017是mongo的標準端口' – ddeadlink