Skip to content

Not connecting to local mongo db #66

Open

Description

@bhiwagade-rahul

After docker-compose up command, I am getting this error

Exception in monitor thread while connecting to server localhost:27017
klov | com.mongodb.MongoSocketOpenException: Exception opening socket
klov | at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70)
klov | at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128)

I checked /usr/local/var/log/mongodb/mongo.log and mongo server I don't see any connection request. Can you please tell me what I am doing wrong?

Mac - Catalina 10.15.6
mongo - mongodb-community@4.4

Activity

  1. bhiwagade-rahul commented on Aug 26, 2020

    @bhiwagade-rahul
    Author

    docker-compose file

    version: '2'
    services:
    klov:
    image: anshooarora/klov:1.0.1
    container_name: klov
    environment:
    - SPRING_DATA_MONGODB_URI=mongodb://127.0.0.1:27017
    ports:
    - 80:80

  2. chipheolm commented on Oct 20, 2020

    @chipheolm

    I got a similar problem on MacOS.
    My workaround :
    fix docker-compose file:
    - SPRING_DATA_MONGODB_URI=mongodb://host.docker.internal:27017
    Hope it can help you.

  3. Naga911 commented on Oct 21, 2020

    @Naga911

    @chipheolm ur code worked, thank you so much, i made mistake not providing "host.docker.internal", provided as localhost and finally its working, extremely happy- thank you for the help bro 👍

  4. akiladevraj commented on Feb 3, 2021

    @akiladevraj

    i was facing problem , klov page was displaying blank, i changed in my docker file as "host.docker.internal", and to my surprise it worked :D . thanks a ton

  5. Kislaya1 commented on Dec 17, 2021

    @Kislaya1

    Hi @anshooarora,

    I tried the above approach but still while running the docker-compose file I am getting issue as below : -

    `host.docker.internal:27017] com.mongodb.diagnostics.logging.SLF4JLogger: Exception in monitor thread while connecting to server host.docker.internal:27017

    com.mongodb.MongoSocketOpenException: Exception opening socket

    at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70)

    at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128)

    at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)

    at java.lang.Thread.run(Thread.java:748)

    Caused by: java.net.ConnectException: Connection refused (Connection refused)

    at java.net.PlainSocketImpl.socketConnect(Native Method)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

    at java.net.Socket.connect(Socket.java:589)

    at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64)

    at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)

    at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)

    ... 3 common frames omitted`

    Can you please help me out.

    Also need to ask if we need to download mongodb seperately or will your docker compose yml will take care of that ?

    Docker Compose YML as : -

    version: '2'
    services:
    klov:
    image: anshooarora/klov:1.0.1
    container_name: klov
    environment:
    - SPRING_DATA_MONGODB_URI=mongodb://host.docker.internal:27017
    ports:
    - 80:80

  6. Kislaya1 commented on Dec 17, 2021

    @Kislaya1

    Had tried with below Docker Compose File as well as thought to install mongodb seperately, but no luck with that. Same error log , @anshooarora can please help me.

    version: '2'
    services:
    db:
    image: mongo:3.2.0
    container_name: mongo-db3
    environment:
    - PUID=1000
    - PGID=1000
    ports:
    - "27017:27017"
    restart: on-failure

    klov:
    image: anshooarora/klov:1.0.1
    container_name: klov
    expose:
    - "80"
    ports:
    - "80:80"
    depends_on:
    - db
    environment:
    - SPRING_DATA_MONGODB_URI=mongodb://mongo-db3:27017

  7. Naga911 commented on Dec 17, 2021

    @Naga911
  8. Kislaya1 commented on Dec 17, 2021

    @Kislaya1

    hi 1. u need to download mongodb separately 2.yml/.yaml file takes image from dockerhub and checks for connection between klov and mongodb version: '2' services: klov: image: anshooarora/klov:1.0.1 container_name: klov environment: - SPRING_DATA_MONGODB_URI=mongodb://host.docker.internal:27017 ports: - 85:80 Regards, Nagaraj
    …
    On Fri, Dec 17, 2021 at 3:39 PM Kislaya Pant @.> wrote: Had tried with below Docker Compose File as well, but no luck with that. @anshooarora https://github.com/anshooarora can please help me. version: '2' services: db: image: mongo:3.2.0 container_name: mongo-db3 environment: - PUID=1000 - PGID=1000 ports: - "27017:27017" restart: on-failure klov: image: anshooarora/klov:1.0.1 container_name: klov expose: - "80" ports: - "80:80" depends_on: - db environment: - SPRING_DATA_MONGODB_URI=mongodb://mongo-db3:27017 — Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALK2UZRJ3BO6KRO67WRNHN3URMD6LANCNFSM4QLV5QAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.>

    Hi Nagaraj

    I had tried to use docker-compose yml file and tried to in-cooperate both mongo db and Klov server there.
    But was facing same issue again. Can you please help me here ?

    My Docker Compose YML file

    version: '2'
    services:
    mymongo:
    image: mongo:3.2.0
    volumes:
    - ./_data:/data/db
    ports:
    - "27017:27017"
    restart: on-failure

    klov:
    image: anshooarora/klov:1.0.1
    container_name: klov
    depends_on:
    - mymongo
    environment:
    - SPRING_DATA_MONGODB_URI=mongodb://host.docker.internal:27017
    ports:
    - 80:80

    Can you please help me.

    Thanks
    Kislaya

  9. RomanRD commented on Aug 13, 2023

    @RomanRD

    hi 1. u need to download mongodb separately 2.yml/.yaml file takes image from dockerhub and checks for connection between klov and mongodb version: '2' services: klov: image: anshooarora/klov:1.0.1 container_name: klov environment: - SPRING_DATA_MONGODB_URI=mongodb://host.docker.internal:27017 ports: - 85:80 Regards, Nagaraj
    …
    On Fri, Dec 17, 2021 at 3:39 PM Kislaya Pant @.> wrote: Had tried with below Docker Compose File as well, but no luck with that. @anshooarora https://github.com/anshooarora can please help me. version: '2' services: db: image: mongo:3.2.0 container_name: mongo-db3 environment: - PUID=1000 - PGID=1000 ports: - "27017:27017" restart: on-failure klov: image: anshooarora/klov:1.0.1 container_name: klov expose: - "80" ports: - "80:80" depends_on: - db environment: - SPRING_DATA_MONGODB_URI=mongodb://mongo-db3:27017 — Reply to this email directly, view it on GitHub <#66 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALK2UZRJ3BO6KRO67WRNHN3URMD6LANCNFSM4QLV5QAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: _@**.**_>

    Hi Nagaraj

    I had tried to use docker-compose yml file and tried to in-cooperate both mongo db and Klov server there. But was facing same issue again. Can you please help me here ?

    My Docker Compose YML file

    version: '2' services: mymongo: image: mongo:3.2.0 volumes: - ./_data:/data/db ports: - "27017:27017" restart: on-failure

    klov: image: anshooarora/klov:1.0.1 container_name: klov depends_on: - mymongo environment: - SPRING_DATA_MONGODB_URI=mongodb://host.docker.internal:27017 ports: - 80:80

    Can you please help me.

    Thanks Kislaya

    Hi Kislaya1! I would really appreciate if you could tell how you solved this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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