1

i'm trying to connect my spring boot app to a remote mongodb database. When i run my app i got this error:

2017年05月25日 15:22:57.829 INFO 4532 --- [*******:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server mongodb-server-address:27017

com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na] at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115) ~[mongodb-driver-core-3.4.2.jar:na] at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:113) ~[mongodb-driver-core-3.4.2.jar:na] at java.lang.Thread.run(Unknown Source) [na:1.7.0_79] Caused by: java.net.ConnectException: Connection refused: connect

asked May 25, 2017 at 14:36

1 Answer 1

2

By default MongoDB only binds to the loopback interface which makes it only accessible from localhost. To change that you need to edit this line in mongod.conf file;

you can change it to allow LAN and local connections or you can remove or comment out that line bind_ip = 127.0.0.1 to allow all connections.

For more info : MongoDB – Allow remote access

answered May 25, 2017 at 14:49
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.