Mongodb-memory-server: [Windows] Error: Status Code is 403 (MongoDB's 404)

Created on 28 Aug 2020  路  26Comments  路  Source: nodkz/mongodb-memory-server

Versions

  • NodeJS: 0.0.0
  • mongodb-memory-server-*: 6.6.6
  • mongodb: 0.0.0
  • mongoose: 5.10.1
  • system: Windows

package: mongo-memory-server

What is the Problem?

Can't start mongodb-memory-server for the tests

Code Example

mongodb-memory-server: checking MongoDB binaries cache... failed to download/install MongoDB binaries. The error: Error: Status Code is 403 (MongoDB's 404)

Do you know why it happenes?

no

bug Needs More Information

Most helpful comment

For fellow Windows user that looking for a copy paste solution, running the following commands will fix this error in your local.

set MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.14.zip
npm i -D mongodb-memory-server

For me this is good enough because our CI runs in Unix which don't hit this error.

All 26 comments

without any system information, the error cannot be solved

It a windows and noticed that doesn't work the latest version of mongo
it is working if I put in the package.json this:
"config": {
"mongodbMemoryServer": {
"debug": "1",
"version": "4.2.3"
}
},
but doesn't with versions greater than that for example latest 4.4.0

are you sure its windows, when es what version and is it windows-server? and how do you configure latest?

We have the same problem. My colleague has it on Mac and I have it on Windows, it happens when we use default version (leave version undefined) or "latest".

When setting the version explicitly to 4.2.3 as mentioned by @ekelvin it works (on Windows).

It started a week or so ago, and it's always worked fine until v6.6.4 (though unsure if related).

@kvanrobbroeck it is already known that the default version (currently) 4.0.14 dosnt work on macos, because that file dosnt exist
-> this can only be fixed within an major patch, because it could break many things

I am also having this issue on windows, however setting the version to 4.2.3 does not fix the issue.

@joan7770 could you provide the debug output? (and maybe try v4.2.3?)

Same as @joan7770

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 4026c8bd2ac06df4
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall [email protected]
7 info lifecycle [email protected]~preinstall: [email protected]
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 4406ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 34ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 1774ms
16 silly install loadAllDepsIntoIdealTree
17 http fetch GET 200 https://registry.npmjs.org/mongodb-memory-server 220ms
18 silly fetchPackageMetaData error for [email protected] No matching version found for [email protected].
19 silly fetchPackageMetaData error for [email protected] No matching version found for [email protected].
20 timing stage:rollbackFailedOptional Completed in 0ms
21 timing stage:runTopLevelLifecycles Completed in 7039ms

...

26 verbose Windows_NT 10.0.18363
27 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
28 verbose node v14.10.0
29 verbose npm  v6.14.8
30 error code ETARGET
31 error notarget No matching version found for [email protected].
32 error notarget In most cases you or one of your dependencies are requesting
32 error notarget a package version that doesn't exist.
32 error notarget
32 error notarget It was specified as a dependency of 'XXXX'
33 verbose exit [ 1, true ]

works fine in macOS

@santiagoalmeidabolannos version 4.2.3 is not meant as in "package-version" it is meant as in "mongod-version"

binary.version

I'm also having the same problem on windows machine. I get the error that it _failed to download/install binaries_ and that I should _Try to use different version 'new MongoMemoryServer({ binary: { version: 'X.Y.Z' } })'_
.Upon doing that I see no change whatsoever and the same error message persists. A workaround that worked for me was to do an npm install that would install all the dependencies (excluding mongodb-memory-server) in package.json file after which i once again run npm install mongodb-memory-server@version_number_to_download. I personally do not like this approach but I need to do this in order to get through the error.
P.S. tested for release 6.3.3. Release 6.7.5 still doesn't work

You need to specify binary version in package.json as described in this thread https://stackoverflow.com/questions/62226563/error-status-code-is-403-mongodbs-404-this-means-that-the-requested-version/62286944#62286944
This helped me, hopefully it works for you guys as well

@austi10 this is mentioned in the README, and the latest version (6.7.6) should provide an more in-depth error (what url actually is the problem), otherwise, could you provide debug output? (best option is to do it with environment variables)

Once the installation was complete, I added started the tests and now the tests do not run. I added "debug": "1" under config object and I get the following:

MongoMS:MongoBinary MongoBinary options: {
  "downloadDir": "C:\\ALPAC StorageHub\\alpac-storage-hub\\node_modules\\.cache\\mongodb-memory-server\\mongodb-binaries",
  "platform": "win32",
  "arch": "x64",
  "version": "latest",
  "checkMD5": false
} +0ms
  MongoMS:MongoBinary MongoBinary: Download lock removed +24ms
  MongoMS:MongoBinary MongoBinary: Mongod binary path: "C:\ALPAC StorageHub\alpac-storage-hub\node_modules\.cache\mongodb-memory-server\mongodb-binaries\latest\mongod.exe" +2ms
  MongoMS:MongoInstance Mongo[59603]: Called MongoInstance._launchKiller(parent: 26652, child: 22492): +0ms
  MongoMS:MongoInstance Mongo[59603]: STDOUT: {"t":{"$date":"2020-09-17T10:45:37.875Z"},"s":"I",  "c":"CONTROL",  "id":4788402, "ctx":"main","msg":"Lock-free reads is disabled."}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:37.892+02:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:37.893+02:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"main","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":10},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":10},"outgoing":{"minWireVersion":0,"maxWireVersion":10},"isInternalClient":true}}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.098+02:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.099+02:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.111+02:00"},"s":"I",  "c":"CONTROL",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":22492,"port":59603,"dbPath":"C:/Windows/TEMP/mongo-mem--26652-3NWBrEzcvl3r","architecture":"64-bit","host":"B107"}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.111+02:00"},"s":"I",  "c":"CONTROL",  "id":23398,   "ctx":"initandlisten","msg":"Target operating system minimum version","attr":{"targetMinOS":"Windows 7/Windows Server 2008 R2"}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.111+02:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.5.0-3164-gcb3d678","gitVersion":"cb3d67879708a44c8ec77247017e6e1b9b14dec6","modules":[],"allocator":"tcmalloc","environment":{"distmod":"windows","distarch":"x86_64","target_arch":"x86_64"}}}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.111+02:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Microsoft Windows 10","version":"10.0 (build 17763)"}}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.111+02:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"127.0.0.1","port":59603},"security":{"authorization":"disabled"},"storage":{"dbPath":"C:\\Windows\\TEMP\\mongo-mem--26652-3NWBrEzcvl3r","engine":"ephemeralForTest"}}}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"E",  "c":"CONTROL",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"Location4939200: Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern majority"}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":15000}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"CONTROL",  "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"REPL",     "id":4784909, "ctx":"initandlisten","msg":"Shutting down the ReplicationCoordinator"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"SHARDING", "id":4784910, "ctx":"initandlisten","msg":"Shutting down the ShardingInitializationMongoD"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"REPL",     "id":4784911, "ctx":"initandlisten","msg":"Enqueuing the ReplicationStateTransitionLock for shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"-",        "id":4784912, "ctx":"initandlisten","msg":"Killing all operations for shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"-",        "id":4695300, "ctx":"initandlisten","msg":"Interrupted all currently running operations","attr":{"opsKilled":1}}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"COMMAND",  "id":4784913, "ctx":"initandlisten","msg":"Shutting down all open transactions"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"REPL",     "id":4784914, "ctx":"initandlisten","msg":"Acquiring the ReplicationStateTransitionLock for shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"INDEX",    "id":4784915, "ctx":"initandlisten","msg":"Shutting down the IndexBuildsCoordinator"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"REPL",     "id":4784916, "ctx":"initandlisten","msg":"Reacquiring the ReplicationStateTransitionLock for shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"REPL",     "id":4784917, "ctx":"initandlisten","msg":"Attempting to mark clean shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.212+02:00"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"CONTROL",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"CONTROL",  "id":4784928, "ctx":"initandlisten","msg":"Shutting down the TTL monitor"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"CONTROL",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"CONTROL",  "id":4784930, "ctx":"initandlisten","msg":"Shutting down the storage engine"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"STORAGE",  "id":20282,   "ctx":"initandlisten","msg":"Deregistering all the collections"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"STORAGE",  "id":22281,   "ctx":"initandlisten","msg":"shutdown: removing fs lock..."}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.213+02:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
  MongoMS:MongoInstance {"t":{"$date":"2020-09-17T12:45:38.214+02:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
  MongoMS:MongoInstance  +532ms
  MongoMS:MongoInstance Mongo[59603]: Mongod instance closed with an non-0 code! +25ms
  MongoMS:MongoInstance Mongo[59603]: CLOSE: 100 +2ms
  MongoMS:MongoInstance Mongo[59603]: [MongoKiller]: Debugger listening on ws://127.0.0.1:59605/d2cbcf27-b10b-485e-921b-e9083abc3ff1
  MongoMS:MongoInstance For help, see: https://nodejs.org/en/docs/inspector
  MongoMS:MongoInstance  +160ms
  MongoMS:MongoInstance Mongo[59603]: [MongoKiller]: Debugger attached.
  MongoMS:MongoInstance  +579ms
  MongoMS:MongoInstance Mongo[59603]: [MongoKiller]: mongo_killer: childPid not alive
  MongoMS:MongoInstance  +162ms
  MongoMS:MongoInstance Mongo[59603]: [MongoKiller]: Waiting for the d +1ms
  MongoMS:MongoInstance Mongo[59603]: [MongoKiller]: ebugger to disconnect...
  MongoMS:MongoInstance  +1ms
  MongoMS:MongoInstance Mongo[59603]: [MongoKiller]: exit - [0,null] +24ms  

@hasezoey : is there a reason to use env variable over defining it in package.json ?

is there a reason to use env variable over defining it in package.json ?

@austi10 it was for the install, otherwise both is ok


your error is Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern majority

you can solve this by either disabling the mentioned option, or using a different engine (like wiredTiger)

@hasezoey thank you for your reply. I never had this error before up until version 6.6.6. Is this due to the new udpate ?

@austi10 maybe because you have set your version to latest and never had version 4.5 (of mongod) installed before (shown in the log that it uses that version, its probably even an pre-release / nightly version)

So it seems like I have 2 issues:

  1. When adding the following to package.json
"config": {
    "mongodbMemoryServer": {
      "version": "latest",
      "debug": "1"
    }
  }

any version (eg. 6.7.6 since i am using mongodb-memory-server and not global or core) other than latest will not download/install. It points to the wrong url for zip file download

  1. @hasezoey i tried both your suggestions but apparently they did not work for me

@austi10 when you are on windows, you can look at the link below what versions are available:
https://dl.mongodb.org/dl/win32

I have already looked into that link and added the version, but a specific version other than latest does not work. I also tried to run the tests inside a docker container and the tests give the same error
'Couldnt download /linux/mongodb-linux-x86_64-debian92-4.0.14.tgz! getaddrinfo ENOTFOUND fastdl.mongodb.org'
and locally on windows I get this error:
'Couldn't download /win32/mongodb-win32-x86_64-4.0.14.zip! getaddrinfo ENOTFOUND fastdl.mongodb.org'
and when I go to the link: https://dl.mongodb.org/dl/win32 and compare the current zip file that I get as an error i.e. /win32/mongodb-win32-x86_64-4.0.14.zip to the one on the mogngodb link, it is win32/mongodb-win32-x86_64-2008plus-ssl-4.0.14.zip
So clearly the download would not work as it is trying to download a non existing file

@austi10 i think increasing the "latest version" variable in the code will fix this, but that is one major patch, and i think this might take a while

in the mean time, you can overwrite the download url, with MONGOMS_DOWNLOAD_URL / (package.json)downloadUrl (needs to contain the full link, example: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz)

PS: this problem only exists because mongodb dosnt name their files in a consistent manner

@hasezoey thank you for the quick reply. Yes this indeed fixed it and my tests also run like before.
P.S. could you also maybe add the downloadUrl property to the documentation under package.json as it would be very helpful for people like me to tweak it :)

@hasezoey I'm wondering about specifying download url in package. Say I am running windows OS on my local machine and i add the download url in package.json to this: https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.14.zip
However my docker would be using linux container and therefore the download url must be: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz. On both the ocassions npm install will be run. So now i run locally, everything works fine since I would be referencing windows download url. But when I would run my application in docker, it would never run due to reference to windows download url. I don't think it is a neat solution/workaround

this config option is meant as an last resort / proxy problems, so yes, it would download the windows one on linux too, the only fix workaround is setting this value somewhere in the code (either by finding what in-code variable it is or by using process.env)

For fellow Windows user that looking for a copy paste solution, running the following commands will fix this error in your local.

set MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.14.zip
npm i -D mongodb-memory-server

For me this is good enough because our CI runs in Unix which don't hit this error.

@malcolm-kee

this worked like a charm! Thanks!

Was this page helpful?
0 / 5 - 0 ratings