Giter Site home page Giter Site logo

Comments (5)

mexin avatar mexin commented on August 20, 2024

I think your problem is because you are only opening port 3000, can you try changing EXPOSE 3000 to EXPOSE 3000 27017 27018 27019 see if that does the trick.

from run-rs.

ghettosamson avatar ghettosamson commented on August 20, 2024

I updated the run command to bind ports 27017, 27018, 27019 and also the EXPOSE directive in the Dockerfile but I still get the connection refused.

from run-rs.

mexin avatar mexin commented on August 20, 2024

I got mine running, try the following when you run the container:
docker run -ti -p 27017-27019:27017-27019 --network="host" --name mongo-runrs YOURIMAGEID
If you don't define --network="host" then you won't be able to connect to the container using localhost.

Hope this helps.

from run-rs.

ghettosamson avatar ghettosamson commented on August 20, 2024

I still get the same error. Note that when we use "host" network mode the published ports are discarded.

docker run -it -p 27017-27019 --network="host" --name my-api --env-file RS.env my-api
WARNING: Published ports are discarded when using host network mode

> [email protected] start /src
> node --inspect server

Debugger listening on ws://127.0.0.1:9229/fe5f0b84-faa4-40eb-bb0f-037ccb27f3fd
For help, see: https://nodejs.org/en/docs/inspector
debug: Mongoose connecting to mongodb://localhost:27017,localhost:27018,localhost:27019/my-db?replicaSet=rs with options  {"useCreateIndex":true,"useNewUrlParser":true,"useUnifiedTopology":true,"useFindAndModify":false,"timestamp":"2020-10-27T12:06:34.295Z"}
info: Request logging set to: false {"timestamp":"2020-10-27T12:06:34.414Z"}
info: MY API Express app starting on port 3000 with log level silly {"timestamp":"2020-10-27T12:06:34.415Z"}
error: UnhandledRejection Error: connect ECONNREFUSED 127.0.0.1:27017 {"timestamp":"2020-10-27T12:07:04.311Z"}
error: connect ECONNREFUSED 127.0.0.1:27017 {"reason":{"type":"ReplicaSetNoPrimary","setName":"rs","maxSetVersion":1,"maxElectionId":"7fffffff00000000000000a5","servers":{},"stale":false,"compatible":true,"compatibilityError":null,"logicalSessionTimeoutMinutes":null,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"commonWireVersion":7}}

from run-rs.

anasanzari avatar anasanzari commented on August 20, 2024

I'm facing the same issue, where client is disconnected arbitrarily saying MongooseServerSelectionError: connection timeout.

from run-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.