21

I just play with mongo shell and came across with Cannot use commands write mode, degrading to compatibility mode.

I connected to remote mongo server (mongolab) and tried to insert new record to collection by my simple script:

// script.js
db = connect(host + ":" + port +"/" + dbName);
db.auth(username, password);

db.test2.insert({ item: "card", qty: 15 });

I run script by mongo script.js and got:

MongoDB shell version: 2.6.3
connecting to: test
connecting to: my.mongolab.com:port/DBname
Cannot use commands write mode, degrading to compatibility mode

What is wrong? Additionally when I executed similar query after connected via mongo my.mongolab.com:port/DBname -u <dbuser> -p <dbpassword> everything is OK.

NHG
  • 5,807
  • 6
  • 34
  • 45
  • 5
    You are connecting to a MongoDB instance that is a lower version than 2.6. Not likely to be of much more future benefit to people as this will go away over time. It's just a warning and does not "generally" affect operations. – Neil Lunn Jul 23 '14 at 17:06
  • @NeilLunn thank's. In fact record was inserted. I didn't notice that, sorry. But what about production environment, can I ignore this warning? – NHG Jul 23 '14 at 17:16
  • @NHG You can always download the correct version (according to `db.version()`) from http://www.mongodb.org/ e.g. https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.7.tgz – Ján Sáreník Oct 13 '14 at 11:25

1 Answers1

26

You are using a shell that's newer than the server it's communicating with.

You can check the server version from the shell via db.version() - to check shell version you use version()

Starting with 2.6 the mongod server started using new write commands which are different than the previously use insert/update/remove op code (this is all described in the MongoDB Wire Protocol).

This is a harmless "informational" warning. It's a good idea to use the same version shell as the server to avoid wondering about such things though.

Asya Kamsky
  • 41,784
  • 5
  • 109
  • 133