简体   繁体   English

Mongo Shell无法连接到本地服务器

[英]Mongo Shell couldn't connect to the local server

I'm starting MongoDB using the following command: 我正在使用以下命令启动MongoDB:

sumeet@sumeet-acer:~$ sudo service mongod start

I get a reply as: 我得到的答复是:

mongod start/running, process 7209
sumeet@sumeet-acer:~$ 

But when I try to enter MongoDB shell by typing mongo I get the following error: 但是,当我尝试通过键入mongo进入MongoDB shell时,出现以下错误:

sumeet@sumeet-acer:~$ mongo
MongoDB shell version: 2.0.4
connecting to: test
Fri Jun 12 14:01:59 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed

By default, mongod and mongos use the 27017 port . 默认情况下, mongodmongos使用27017 port Without any option, the client will try to connect to a server running on localhost and listening at that port. 如果没有任何选择,客户端将尝试连接到在localhost上运行并在该端口上侦听的服务器。

A few general advices here: 这里有一些一般建议:

  1. check if the mongod server is really running ( ps -edf | grep mongod ); 检查mongod服务器是否真的在运行( ps -edf | grep mongod );
  2. check if it uses the default port (look in the config file 1 , or use nmap localhost -p0-65535 or netstat | grep 27017 ); 检查它是否使用默认端口(在配置文件1中查找,或使用nmap localhost -p0-65535netstat | grep 27017 );
  3. if mongod is not running, check in the log 2 for clues about what goes wrong. 如果mongod不在运行,请在日志2中检查出哪里出错的线索。


1 /etc/mongodb.conf (on Debian-like systems at least) 1 /etc/mongodb.conf (至少在类似Debian的系统上)
2 /var/log/mongodb (on Debian-like systems at least) 2 /var/log/mongodb (至少在类似Debian的系统上)

The default IP and Port for MongoDB is 127.0.0.1 & 27017. MongoDB的默认IP和端口是127.0.0.1和27017。

If you are using config file for specifying settings than re-verify IP & Port mentioned in it. 如果您正在使用配置文件指定设置,然后重新验证其中提到的IP和端口。

If you are going with default option than mongod should function as expected. 如果要使用默认选项,则mongod应该可以按预期运行。

try mongo 127.0.0.1:27017 尝试mongo 127.0.0.1:27017

this worked for me For MongoDB 2.2.2 running on Ubuntu 12.10, it's in /var/lib/mongodb/mongod.lock 对于在Ubuntu 12.10上运行的MongoDB 2.2.2而言,它在/var/lib/mongodb/mongod.lock中

and after that running the repair command 然后运行修复命令

sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/

courtesy: https://stackoverflow.com/a/13700262/4907105 礼貌: https : //stackoverflow.com/a/13700262/4907105

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到服务器127.0.0.1 shell / mongo.js - couldn't connect to server 127.0.0.1 shell/mongo.js Mongo:无法连接到服务器127.0.0.1:27017 src / mongo / shell / mongo.js:145 - Mongo: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 mongo - 无法连接到服务器 127.0.0.1:27017 - mongo -couldn't connect to a server 127.0.0.1:27017 mongo - 无法连接到服务器 127.0.0.1:27017 - mongo - couldn't connect to server 127.0.0.1:27017 MongoDB - 无法连接到服务器 127.0.0.1:27017,原因是:连接被拒绝:connect@src/mongo/shell/mongo.js:374:17 - MongoDB - couldn't connect to server 127.0.0.1:27017, caused by :Connection refused : connect@src/mongo/shell/mongo.js:374:17 无法连接到 mongodb 错误:无法连接到 src/mongo/shell/mongo.js:L112 处的服务器 127.0.0.1:27017 - Unable to connect to mongodb Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 Windows上的本地Mongo-无法连接到服务器127.0.0.1:27017,连接尝试失败 - Local Mongo on Windows - couldn't connect to server 127.0.0.1:27017, connection attempt failed Mongo Shell无法连接到服务器 - Mongo shell can't connect to server Mongo:在mongodb.conf中取消注释和评论auth = true后,无法在src / mongo / shell / mongo.js:145连接到服务器127.0.0.1:27017 - Mongo: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 after un-commenting and commenting auth=true in mongodb.conf Errr 'mongo.js:L112 错误:无法连接到服务器 127.0.0.1:27017 在 src/mongo/shell/mongo.js:L112' - Errr 'mongo.js:L112 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM