Closed floriandotorg closed 3 years ago
What is the IP address for "mongo"? Maybe it is a configuration problem?
Hey Zook, mongo is the DNS name in a Docker configuration, that's completely fine. It's really a problem with the mongo driver itself, it always tries to connect to localhost if the port is 27017. I think the error lies in the UrlParser.
So, after a long while back to this issue. I build a demo app, using you configuration and I get this log output:
[error] Mongo.MongoDBConnection (#PID<0.473.0>) failed to connect: ** (Mongo.Error) mongo:27017 tcp connect: connection refused - :econnrefused
[error] Mongo.MongoDBConnection (#PID<0.473.0>) failed to connect: ** (Mongo.Error) mongo:27017 tcp connect: connection refused - :econnrefused
So, the URL-Parser does not change the hostname mongo
to localhost
.
database_config = Application.get_env(:check_domain, :db_config)
children = [
%{
id: Mongo,
start: {Mongo, :start_link, [database_config]}
},
CheckDomainWeb.Endpoint
]
And the config looks like that:
config :check_domain, :db_config,
name: :mongo,
url: "mongodb://mongo:27017/meteor"
Unfortunately I'm not able to reproduce your issue. Maybe it is already resolved. Can I close this issue?
Thanks for your effort. I will update the package and check on our side.
I noticed today, that the mongo driver ignores the domain name when the port is 27017, example code:
This config works:
This config doesn't:
It tries to connect to localhost instead of mongo only when the port 27017:
[error] Mongo.MongoDBConnection (#PID<0.1025.0>) failed to connect: ** (Mongo.Error) localhost:27017 tcp connect: connection refused - :econnrefused