Skip to content
Advertisement

MongoDB trying to connect to localhost, Why?

I am currently developing a Java application connected to a remote MongoDB databse.

I have implemented the authentication methods fallowing the mongo guides:

JavaScript

The app connect properly to the database but there is a thing i can’t understand.It connects well to the remote server,but I don’t know why it try to connect to localhost:27017.

JavaScript

So, how can I tell it I don’t want to connect to localhost ?

Thanks

Advertisement

Answer

You can exclude Mongo auto connect/(localhost:27017) by adding below annotation on spring boot Application.java.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement