I have this Go Code to connect to my Mongo Cloud Database:
func connectToDataBase() {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
client, err := mongo.Connect(ctx, options.Client().ApplyURI(dbURL))
if err != nil {
log.Fatal("Error connecting to Database: ", err.Error())
}
DB = client.Database("storyfactory")
}
I already ran this code on a Windows machine, and it worked. Now I tried to run it on ubuntu, and I get following error:
2019/04/13 00:20:37 Error connecting to Database: error parsing uri (mongodb+srv://User:[email protected]/test?retryWrites=true): lookup cluster0-gpxjk.gcp.mongodb.net on 127.0.0.53:53: cannot unmarshal DNS message
exit status 1
I don't know, why it worked on windows, and now it doesn't on ubuntu.
Thanks for your help!