question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Solved] Cannot connect to mongoDB

See original GitHub issue

I’ve deployed a mongo service with the following command:

fandogh service deploy \
 --image library/mongo \
 --version latest \
 --port 27017 \
 --name mongo-service-name

But I can’t connect to database!

  • with mongodb+srv://mongo-service-name-account.fandogh.cloud/ I get:
connection error: { Error: querySrv ENODATA _mongodb._tcp.mongo-service-name-account.fandogh.cloud
    at errnoException (dns.js:28:10)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:216:19)
  code: 'ENODATA',
  errno: 'ENODATA',
  syscall: 'querySrv',
  hostname: '_mongodb._tcp.mongo-service-name-account.fandogh.cloud' }
  • and with mongodb://public-mongo-sadra.fandogh.cloud/ I get:
connection error: { Error: failed to connect to server [mongo-service-name-account.fandogh.cloud:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 165.227.244.57:27017]
    at Pool.<anonymous> (/MY_DIR/node_modules/mongodb-core/lib/topologies/server.js:564:11)
    at emitOne (events.js:96:13)
    at Pool.emit (events.js:191:7)
    at Connection.<anonymous> (/MY_DIR/node_modules/mongodb-core/lib/connection/pool.js:317:12)
    at Object.onceWrapper (events.js:293:19)
    at emitTwo (events.js:106:13)
    at Connection.emit (events.js:194:7)
    at Socket.<anonymous> (/MY_DIR/node_modules/mongodb-core/lib/connection/connection.js:246:50)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at emitErrorNT (net.js:1289:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
  name: 'MongoNetworkError',
  errorLabels: [ 'TransientTransactionError' ] }

So what’s the solution?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
s-sorooshcommented, Oct 17, 2018

@sadra , your services inside your namespace are accessible through their names.

So if you mongo service name is mongo1, then your connection string will be sth like: mongodb://mongo1/DB_NAME

2reactions
MahdiZareiecommented, Oct 17, 2018

Dear Sadra, Unfortunately it’s not possible to use a non-HTTP connection to connect to your MongoDB from outside of your fandogh namespace internal network at the moment. any service which needs to query MongoDB needs to be inside your namespace private network, so you should consider running your service on Fandogh too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: couldn't connect to server 127.0.0.1:27017 - MongoDB
Your connection from client to server is blocked by firewall or network configuration ; A MongoDB server is not listening on the requested...
Read more >
couldn't connect to server 127.0.0.1:27017 at src/mongo/shell ...
1. Make sure mongodb is up and running · 2. For linux access as sudo and for windows if connecting localhost turning off...
Read more >
Smart ways to fix MongoDB not connecting error - Bobcares
MongoDB not connecting error happens due to failed MongoDB server, firewall restrictions, authentication failure, bad connection string, ...
Read more >
Mongodb Error: couldn't connect to server 127.0.0.1:27017
Cannot connect to the MongoDB at localhost:27017. Solve Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: in less ...
Read more >
Mongodb Error : couldn't connect to server 127.0 ... - YouTube
solved : Mongodb Error : couldn't connect to server 127.0.0.1:27017, connection attempt failed : solved in less than 2 minutes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found