cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to use on prem Mysql server as we are not able to resolve the hostname

User16753724663
Valued Contributor

while connecting from notebook, it returns the error unable to resolve name.

1 REPLY 1

User16753724663
Valued Contributor

Since we are unable to resolve hostname, it point towards the DNS issue. We can use custom dns using init script and add in the cluster:

%scala
dbutils.fs.put("/databricks/<directory>/dns-masq.sh";,"""
#!/bin/bash
########################################
Configure on-prem dns access.
########################################
 
sudo apt-get update -y
sudo apt-get install dnsmasq -y --force-yes
 
## Add dns entries for internal your-company.net name servers
echo server=/databricks.net/10.X.Y.Z | sudo tee --append /etc/dnsmasq.conf
 
## Find the default DNS settings for the EC2 instance and use them as the default DNS route
 
ec2_dns=cat /etc/resolv.conf | grep "nameserver"; | cut -d' ' -f 2
echo "Old dns in resolv.conf $ec2_dns"
 
echo "server=$ec2_dns" | sudo tee --append /etc/dnsmasq.conf
 
## configure resolv.conf to point to dnsmasq service instead of static resolv.conf file
mv /etc/resolv.conf /etc/resolv.conf.orig
echo nameserver 127.0.0.1 | sudo tee --append /etc/resolv.conf
sudo service dnsmasq restart
""", true)

https://kb.databricks.com/cloud/custom-dns-routing.html

Another way is to use the IP address to connect.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!