Comments (6)
It's very strange. By provided debug output all looks legit. mongodb-memory-server works as expected. The problem somewhere in your test file or machine.
Can you provide your test case?
PS. Also try to change obtained host in uri
:
let uri = await mongod.getConnectionString();
uri = uri.replace('localhost', '127.0.0.1'); // maybe some problems with resolving `localhost` on you machine, eg. it points on ipv6 or other ip address than 127.0.0.1
PSS. Maybe helps some timeout before connection:
const uri = await mongod.getConnectionString();
await new Promise(resolve => { setTimeout(resolve, 5000); }); // lets wait 5 second before connection to MongoDB
Firstly we need to resolve the error and obtain a working solution. After that we can optimize it, put fix to the code or add some note to README.md.
from mongodb-memory-server.
Please use debug: true
option and post here your output.
from mongodb-memory-server.
Mongo[53357] Starting MongoDB instance with following options: {"port":53357,"dbName":"c7f67e84-beb8-4c69-8c5c-d6f884924534","uri":"mongodb://localhost:53357/c7f67e84-beb8-4c69-8c5c-d6f884924534","storageEngine":"ephemeralForTest","dbPath":"/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF"} +0ms
Mongo[53357] MongoBinary: Mongod binary path: /Users/guyromm/.mongodb-binaries/latest/mongod +2ms
Mongo[53357] MongoBinary: Download lock removed +6ms
Mongo[53357] 2018-08-27T06:44:24.285+0300 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
Mongo[53357] +26ms
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] MongoDB starting : pid=44945 port=53357 dbpath=/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF 64-bit host=Guys-MacBook-Pro.local
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] db version v3.7.9-154-g51dce76
Mongo[53357] +11ms
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] git version: 51dce76324173089098e8c9fd09e46b98b32adc4
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] allocator: system
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] modules: none
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] build environment:
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] distarch: x86_64
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] target_arch: x86_64
Mongo[53357] 2018-08-27T06:44:24.297+0300 I CONTROL [initandlisten] options: { net: { port: 53357 }, security: { authorization: "disabled" }, storage: { dbPath: "/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF", engine: "ephemeralForTest" } }
Mongo[53357] +0ms
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten]
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** NOTE: This is a development version (3.7.9-154-g51dce76) of MongoDB.
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** Not recommended for production.
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten]
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
Mongo[53357] +6ms
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten]
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten]
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** NOTE: The ephemeralForTest storage engine is for testing only.
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten] ** Do not use in production.
Mongo[53357] +0ms
Mongo[53357] 2018-08-27T06:44:24.303+0300 I CONTROL [initandlisten]
Mongo[53357] +1ms
Mongo[53357] 2018-08-27T06:44:24.308+0300 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 32c711d6-c0c5-44bd-8f0f-539902c3b457
Mongo[53357] +4ms
Mongo[53357] 2018-08-27T06:44:24.308+0300 I COMMAND [initandlisten] setting featureCompatibilityVersion to 4.0
Mongo[53357] +1ms
Mongo[53357] 2018-08-27T06:44:24.309+0300 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: 505eae10-04c7-42c6-9e38-6b8038c037b8
Mongo[53357] +0ms
Mongo[53357] 2018-08-27T06:44:24.309+0300 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/folders/81/v_z30jtn7rx1l6jwphrbr5000000gn/T/mongo-mem-449442g7byUjJf2dF/diagnostic.data'
Mongo[53357] +0ms
Mongo[53357] 2018-08-27T06:44:24.311+0300 I NETWORK [initandlisten] waiting for connections on port 53357
Mongo[53357] +2ms
Mongo[53357] MongodbInstance: is ready! +0ms
Than this error on connect
failed to connect to server [localhost:53357] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:53357]
from mongodb-memory-server.
BTW what OS do you using?
from mongodb-memory-server.
Thank you very much.
This fixed it - uri = uri.replace('localhost', '127.0.0.1')
I'm, using OSX
from mongodb-memory-server.
Thanks for the feedback. For a new package version, this problem will be fixed.
from mongodb-memory-server.
Related Issues (20)
- Randomizing db names for each test
- GridFS streams not working correctly HOT 4
- Jest + mongodb-memory-server + mongoose - Calling 'find' hangs indefinitely HOT 2
- Invalid version reported for version strings ending in -latest HOT 2
- Ubuntu >= 22.04 is unsupported when using MongoDB >= 6.0.4 HOT 7
- _startUpInstance threw a Error: TypeError: (intermediate value).finally is not a function HOT 3
- Mongod instance closed with code "127" HOT 7
- Case: InMemory DB refuses to update after Making changes to model HOT 7
- Library is missing or cannot be opened: "libcrypto.so.1.1" HOT 2
- 9.1.8 not working out of the box for node:20 docker (LTS images) HOT 5
- ReplicaSet - emulate replication lag HOT 1
- Issue downloading mongo binaries with Nexus set as MONGOMS_DOWNLOAD_MIRROR HOT 8
- Error when trying to run tests HOT 1
- Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1" HOT 8
- Requested Version "6.0.14" is not available for "Debian 12"! Available Versions: ">=7.0.3" HOT 1
- Mongod sometimes fails to start due to ETXTBSY HOT 10
- The download of the mongodb binary is corrupted when using a hoisted dependency in a monorepo HOT 4
- How to initialize data/collections/indexes on startup? HOT 1
- Fix Documentation path because of repository transfer HOT 1
- Occasional `StdoutInstanceError: Port "39697" already in use` with v10.0.0 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongodb-memory-server.