Java无法连接MongoDB问题
背景介绍:
由于开发用的Linux服务器在一个相对封闭的环境中,只有通过SSH访问22端口。于是就用putty做了一个SSH forwarding,将本机的27018端口映射到远程的27017端口。在cmd中通过mongo localhost:27018成功连接,并且进行了操作。
现象:
在程序中通过
- Mongo mongo = new Mongo("localhost", 27018);
- Caused by: java.io.IOException: couldn't connect to [3CNL07745/172.28.220.64:27018] bc:java.net.ConnectException: Connection refused: connect
- at com.mongodb.DBPort._open(DBPort.java:206)
- at com.mongodb.DBPort.go(DBPort.java:94)
- at com.mongodb.DBPort.go(DBPort.java:75)
- at com.mongodb.DBPort.call(DBPort.java:65)
- at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:207)
- ... 37 more
相关推荐
lbyd0 2020-11-17
BigYellow 2020-11-16
sushuanglei 2020-11-12
我心似明月 2020-11-09
zhushenghan 2020-11-09
sunnnyduan 2020-10-16
不要皱眉 2020-10-14
xiaohai 2020-09-29
songxiugongwang 2020-09-22
萌亖 2020-09-17
LuckyLXG 2020-09-08
sdmzhu 2020-09-01
mkhhxxttxs 2020-09-16
xiaohai 2020-09-16
newcome 2020-09-09
jaylong 2020-08-19
大秦铁骑 2020-08-19
thatway 2020-08-19