Skip to content

Issues connecting to Mongo Atlas #116

Open
@gillchristian

Description

@gillchristian

I'm trying to connect to Mongo Atlas but to no success. Getting the following error:

Network.BSD.getHostByName: does not exist (no such host entry)

I've tried the suggestions from #84 but it seems like the issue is different.

This is how I connect:

import qualified Database.MongoDB as DB
import qualified Database.MongoDB.Transport.Tls as DBTLS

runDb :: DB.Action IO a -> App a
runDb action = do
  -- ...
  pipe <- liftIO $ case env of
    Production -> DBTLS.connect (dbHostname dbConf) (DB.PortNumber 27017)
    Development -> DB.connect $ DB.host $ dbHostname dbConf
  -- ...

Code is open source, rest can be found here.

On Development mode connecting to a local db it works fine (dbHostname: "127.0.0.1").

But when trying to connect to Mongo Atlas, either by using DBTLS.connect or DB.connect it does not work. Either by trying with the full connect URL provided by Mongo Atlas or only the host

dbHostname: "mongodb+srv://<user>:<password>@xxxxxx-xxxxx.gcp.mongodb.net/test?retryWrites=true&w=majority"

dbHostname: "xxxxxx-xxxxx.gcp.mongodb.net"

As error is from Network.BSD.getHostByName I'm not sure if issue should be opened here or not.

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