我来自riak和redis,在那里我从未有过这个服务启动或互动的问题。

这是蒙古人普遍存在的问题,我对此一无所知。重启也无济于事。我是蒙哥的新手。

mongo
MongoDB shell version: 2.2.1
connecting to: test
Fri Nov  9 16:44:06 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

这是我在日志里看到的。

 now open)
Fri Nov  9 16:44:34 [conn47] end connection 10.29.16.208:5306 (1 connection now open)
Fri Nov  9 16:45:04 [initandlisten] connection accepted from 10.29.16.208:5307 #48 (2 connections now open)
Fri Nov  9 16:45:04 [conn48] end connection 10.29.16.208:5307 (1 connection now open)
Fri Nov  9 16:45:04 [initandlisten] connection accepted from 10.29.16.208:5308 #49 (2 connections now open)
Fri Nov  9 16:45:04 [conn49] end connection 10.29.16.208:5308 (1 connection now open)
Fri Nov  9 16:45:34 [initandlisten] connection accepted from 10.29.16.208:5316 #50 (2 connections now open)
Fri Nov  9 16:45:34 [conn50] end connection 10.29.16.208:5316 (1 connection now open)
Fri Nov  9 16:45:34 [initandlisten] connection accepted from 10.29.16.208:5317 #51 (2 connections now open)
Fri Nov  9 16:45:34 [conn51] end connection 10.29.16.208:5317 (1 connection now open)
Fri Nov  9 16:46:04 [initandlisten] connection accepted from 10.29.16.208:5320 #52 (2 connections now open)
Fri Nov  9 16:46:04 [conn52] end connection 10.29.16.208:5320 (1 connection now open)
Fri Nov  9 16:46:04 [initandlisten] connection accepted from 10.29.16.208:5321 #53 (2 connections now open)
Fri Nov  9 16:46:04 [conn53] end connection 10.29.16.208:5321 (1 conn

当前回答

在我的例子中:

首先我打开配置文件

sudo vi /etc/mongodb.conf

像这样注释IP和端口

#bind_ip = 127.0.0.1
#port = 27017

然后重新启动mongodb

sudo service mongodb restart
sudo service mongod restart

最后是工作:D

finn@Finn ~ $ mongo
MongoDB shell version: 2.4.9
connecting to: test
> exit

其他回答

Resolved. This problem could be solved by the below mentioned 4 steps 1) Remove .lock file sudo rm /var/lib/mongodb/mongod.lock 2) repair the mongodb mongod -–repair 3) start the mongod server sudo service mongod start 4) start the mongo client mongo For more details take a look at http://shakthydoss.com/error-couldnt-connect-to-server-127-0-0-127017-srcmongoshellmongo-js-exception-connect-failed/ http://shakthydoss.com/technical/error-couldnt-connect-to-server-127-0-0-127017-srcmongoshellmongo-js-exception-connect-failed/

错误:无法连接到127.0.0.1:27017服务器,连接尝试失败:SocketException:错误连接到127.0.0.1:27017::导致::没有连接可以建立,因为目标机器主动拒绝它。

这个错误是因为Mongo服务器被关闭

遵循以下步骤

打开任务管理器 进入>服务 找到MongoDB 右键单击并选择Start

苹果操作系统

检查状态

brew services list

喜欢的东西:

Name    Status  User Plist
mongodb stopped  

启动它

brew services start mongodb

再试一次

Mongo或Mongo—端口27017

在我的例子中:

首先我打开配置文件

sudo vi /etc/mongodb.conf

像这样注释IP和端口

#bind_ip = 127.0.0.1
#port = 27017

然后重新启动mongodb

sudo service mongodb restart
sudo service mongod restart

最后是工作:D

finn@Finn ~ $ mongo
MongoDB shell version: 2.4.9
connecting to: test
> exit

如果你通过brew安装(在osx上) 首先执行sudo mkdir /data/db命令 通过输入mongod启动mondoDB Daemon(让它打开),然后 在新终端选项卡中输入mongo运行mongo