MongoDB Connection Failed

54 views
Skip to first unread message

Ali Hassan

unread,
Apr 6, 2020, 9:28:03 AM4/6/20
to golang-nuts
clientOptions := options.Client().ApplyURI("mongodb://localhost:27017") // Connect to MongoDB client, err := mongo.Connect(context.TODO(), clientOptions) if err != nil { log.Fatal(err) } // Check the connection err = client.Ping(context.TODO(), nil) if err != nil { log.Fatal(err) } fmt.Println("Connected to MongoDB!")


Error receive when i execute my programCapture.JPG


Gregor Best

unread,
Apr 7, 2020, 1:56:20 AM4/7/20
to golan...@googlegroups.com

Hi Ali,

it looks like there's nothing listening on localhost port 27017. Maybe the mongod log has some more information for you.

On 06.04.20 15:28, Ali Hassan wrote:
clientOptions := options.Client().ApplyURI("mongodb://localhost:27017") // Connect to MongoDB client, err := mongo.Connect(context.TODO(), clientOptions) if err != nil { log.Fatal(err) } // Check the connection err = client.Ping(context.TODO(), nil) if err != nil { log.Fatal(err) } fmt.Println("Connected to MongoDB!")


Error receive when i execute my programCapture.JPG

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/bfd30b79-343e-48cc-b853-1d42fe9cd825%40googlegroups.com.
-- 
--
  Gregor Best
  be...@pferdewetten.de
Reply all
Reply to author
Forward
0 new messages