Problem in connecting to Mongodb Atlas


I am trying to connect to Mongodb database in Atlas. I am getting the error

ERROR MongoDB Reader 0:1 Execute failed: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {}}]

The link for the connection is mongodb+srv://
I entered the data as:
Port: 27017
Database: db_name
Authentication Database : admin
I specified the collection I need in the field collection too
Username and password are obvious.
I don’t get what I did wrong here? Is there any solution to my problem?

1 Like

I think in this case the problem is not MongoDB, but that your computer cannot even connect to that server. UnknownHostException means that your computer tries to get the IP address for but the DNS server cannot resolve it. Maybe you need to use a proxy or have a typo in the host name?
Kind regards,

@AlexanderFillbrunn, I had a look at this too and having created a mongodb atlas database hit the same issue.

As well as java complaining, I cannot even ping as that gives me an unreachable error (or might be a unknown host error… Can’t remember and I’m not at the pc today). Could be it’s set to not respond to ping but the message indicated that ping wasn’t even getting that far

I tried changing my dns to something other than my isp supplied one (opendns, I think) but with no improvement. I did wonder if other people are actually able to ping directly. It seems very strange. I’ve seen other people reporting similar on stackoverflow.

You are right that java reporting host unreachable does indicate connectivity or dns issue.

Oddly, I can reach the database via the mongodb shell installed on my pc, and through the mongodb compass application, so the connectivity is clearly there, but not for ping or java…


a revised version of the MongoDB nodes will be published with the upcoming 4.4 release. This includes support for MongoDB Atlas. If you want to give it a try download the nightly build from here. Once you have installed the MongoDB extension you will find the new MongoDB Connector node where you have to use SRV as connection type as shown below:

When entering the hostname remove the port since this is not required for SRV.
Let us know if this works for you.