Connection fails when using `127.0.0.1`
TaKO8Ki opened this issue · 5 comments
TaKO8Ki commented
friendbear commented
I have a question for @TaKO8Ki, I keep getting an error with name resolution in gobang.
Did you use Cloudware for name resolution in gobang?
This Case
MongoDB Name Resolved implementation.
use mongodb::bson::{self, doc, Bson};
use std::env;
use std::error::Error;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// Load the MongoDB connection string from an environment variable:
let client_uri =
env::var("MONGODB_URI").expect("You must set the MONGODB_URI environment var!");
// A Client is needed to connect to MongoDB:
// An extra line of code to work around a DNS issue on Windows:
let options =
ClientOptions::parse_with_resolver_config(&client_uri, ResolverConfig::cloudflare())
.await?;
let client = mongodb::Client::with_options(options)?;
// Print the databases in our MongoDB cluster:
println!("Databases:");
for name in client.list_database_names(None, None).await? {
println!("- {}", name);
}
Ok(())
}
sainu commented
A similar error occurred when I tried to connect from gobang to mysql running in a docker container.
The information for the connection is as follows.
docker container
NAME COMMAND SERVICE STATUS PORTS
sample_app-db-1 "docker-entrypoint.s…" db running 0.0.0.0:9989->3306/tcp
database
- user: root
- password: password
$HOME/.config/gobang/config.toml
[[conn]]
type = "mysql"
user = "root"
password = "password"
host = "0.0.0.0"
port = 9989
And I got the same error message.
Additional information: I was able to connect to this database from tools such as mysql CLI
, mycli
, and Sequel Ace.app
.
TaKO8Ki commented
@sainu
Could you use localhost
as a host name if you have time? In the following case, it solved the problem.