An example usage of requests-doh library in vscode (theme: Monokai)

Link github repository:

It's awful to use DNS resolver from your ISP. Sometimes it's working, sometimes it don't. This is why public DNS resolvers is created to help you get rid of this (also to protect your privacy too 😉).

requests-doh are using dnspython library to query DoH to public DNS servers.


requests-doh can be installed from PyPI (Python Package Index)

# For Windows
py -3 -m pip install requests-doh

# For Unix-based systems
python3 -m pip install requests-doh


Using requests-doh is simple as importing requests-doh module, create DoH requests session, and then you're done !

from requests_doh import DNSOverHTTPSSession

# By default, DoH provider will be set to `cloudflare`
# You can change this to any provider 
# See
# for available DoH providers

session = DNSOverHTTPSSession(provider='cloudflare')
r = session.get('')