cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Can't connect to Atlas

attie_bc
New Contributor III

I have this:

connectionString='mongodb+srv://user:pw@something.jghu.mongodb.net/?retryWrites=true&w=majority&appName=dbricks&tls=true'
database='dealflow'
collection='activities'

frame = spark.read.format("mongodb") \
    .option("spark.mongodb.read.connection.uri", connectionString) \
    .option("spark.mongodb.read.database", database) \
    .option("spark.mongodb.read.collection", collection) \
    .option("spark.mongodb.read.readPreference.name", "primaryPreferred") \
    .load()

display(frame)

that times out.

When I telnet I get a "server lookup failure". This only happens on Databricks.

1 ACCEPTED SOLUTION

Accepted Solutions

attie_bc
New Contributor III

Thank you. The issue in the end was that Amazon VPC blocked the 27017 port. I had to add an outbound rule on a Security Group to allow access. That solved it.

View solution in original post

2 REPLIES 2

Isi
Contributor III

hey @attie_bc 

I guess you are using All-pourpouse cluster, have you tried

curl https://www.google.com

Maybe your cluster doesnโ€™t have internet access? If thatโ€™s the case, DNS resolution for your MongoDB Atlas SRV connection string will fail, which would explain the โ€œserver lookup failureโ€ youโ€™re seeing.

If the curl fails too, then your cluster likely doesnโ€™t have outbound internet access, which is required to resolve SRV records like *.mongodb.net.

Also, two other things worth checking:

MongoDB Atlas IP Access List
Even if DNS resolves correctly, Atlas will block the connection unless your Databricks clusterโ€™s IP is whitelisted in the Network Access section. Docs

SRV Connection String Dependency on DNS
The SRV connection string (mongodb+srv://...) depends on resolving DNS SRV records. In some restricted environments (like private VPCs), this wonโ€™t work without proper DNS forwarding. Docs  

Hope this helps ๐Ÿ™‚

Isi

attie_bc
New Contributor III

Thank you. The issue in the end was that Amazon VPC blocked the 27017 port. I had to add an outbound rule on a Security Group to allow access. That solved it.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now