OS Error: No address associated with hostname

I’m getting the following error when trying to connect to mongodb database in a flutter app:

ConnectionException (MongoDB ConnectionException: Could not connect to xxxxxx.mongodb.net:27017

  • SocketException: Failed host lookup: ‘xxxxx.mongodb.net’ (OS Error: No address associated with hostname, errno = 7))

There is no problem when I try to connect while I am using Wi-Fi, but when I connect to 4G this message appears.

I’m out of ideas and trying several Stackoverflow solutions have taken me back to square one.

most likely, your URI is wrong. xxxxx.mongodb.net is a cluster address and you are trying to connect with mongodb:// rather than mongodb+srv://.

less likely your 4G provider uses deprecated DNS software that cannot resolve SRV records, override the DNS config to use

my ISP force us to use their DNS, even if I use google DNS it doesn’t work,

I’m using mongodb:// to connect because I can’t use mongodb+srv:// Except when I use a vpn the mongodb+srv:// works.

The problem is that even mongodb:// does not work when I connect to 4G.

Did you get my point?
mongodb+srv:// I can use it if I’m using my home internet, it doesn’t work if I use 4G

The mongodb:// works when connected to the home internet only, but when using the 4g network, it does not work.

it is not possible to connect to the database via 4G at all.

the full message is:

The country I live in has VERY restrictive internet policies.

Most of the ports are closed and they use DPI to fully control the Internet.
I’m in prison not a country.

Is there a way to bypass it other than using a vpn?

If SRV records are not working you may try the long URI as supply by the Atlas UI for your cluster.

it works only when I use Wi-Fi but not 4G