Search code examples
mongodbamazon-route53cnamemongodb-atlas

Create custom domain with mongoDB atlas using CNAME record


I am setting up a mongoDB cluster on mongoDB atlas.

To connect to the cluster you get an URL like cluster-01.mongodb.net. For convenience reasons I tried to set up a CNAME record on AWS Route53 pointing from cluster-01.my-company.co to the mongoDB cloud URL above.

When connecting to the cluster:

mongo "mongodb+srv://mongo-01.my-company.co/test" --username user

But I am getting the following error:

DNSHostNotFound: Failed to look up service "_mongodb._tcp.mongo-01.my-company.co": Undefined error: 0

Has anyone experiences in setting up a CNAME record for a mongoDB cloud cluster?


Solution

  • This is not possible. See https://jira.mongodb.org/browse/CDRIVER-2556 and in particular this commit https://github.com/mongodb/specifications/commit/3c1ff124ce47fa7b5d97b336028e575efd0e3d1e , which specifically disallows using CNAME with mongo+srv.