Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Unable to connect to Atlas due to DNS connectivity issues #358

@JD-Robertson

Description

@JD-Robertson

I've run into an issue where connecting to Atlas using a mongodb+srv:// URL is failing on a specific set of AWS Windows 10 instances that my company uses for testing. We have a mix of C# and Elixir client code and only the Elixir code was failing.

I did some debugging to figure out what was going on, and found code in url_parser.ex that hardcodes 4.2.2.1 as the name server to use to lookup the records needed to decode the +srv URL. This AWS instance is pretty locked down and it is not allowed to access that server. This can be tested on the command line using nslookup.

A simpler reproducing case is to configure the Windows firewall to block connections to that specific address. Not a likely use case, but gives the same result.

I did some additional digging to figure out why the code was manually specifying a DNS server in the first place and found this issue, where apparently Erlang doesn't know how to properly retrieve the DNS configuration from the OS on Windows.

You can workaround this issue by manually setting \HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NameServer to an approved name server so that Erlang will actually see the configuration (not desirable). I've also verified that changing the hardcoded value in url_parser.ex resolved the issue, but that's also not a real fix.

I tried using :inet_db.add_ns() to add additional configuration in our code prior to calling into the MongoDB driver, but that doesn't work. It looks like the inet_db configuration is scoped to an individual Erlang process. Changing it in one process doesn't affect others.

I'd appreciate thoughts on how to address this. It's an internal issue for us at the moment, and not a showstopper, but business ownership is concerned that this end users will start hitting this eventually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions