Insert Not Permitted: Code 13 in node js realm app

I have been working on mongoDb Realm for My Android Application and Web App. So the Inserting Document part while logging in works fine for my android application but gives error in node.js

Error: Insert Not Permitted Code-13


const Realm = require("realm");
const BSON = require("bson");

const app = new Realm.App({ id: "debuggers-lzxyc" });

const TaskSchema = {
  name: 'Task',
  properties: {
    _id: 'objectId',
    _partition: 'string?',
    name: 'string',
    status: 'string',
  primaryKey: '_id',

const email="";
const password="nikhil103";

// Create an email/password credential
const fun=async ()=>{

try {
  //const credentials = await app.emailPasswordAuth.registerUser(email, password);
  const credentials = Realm.Credentials.emailPassword(
  const user = await app.logIn(credentials);
  console.log("Successfully logged in!",;
  const mongodb = app.currentUser.mongoClient("mongodb-atlas");
  const users = mongodb.db("Debuggers").collection("Events");
  const result = await users.insertOne({

  realm.write(() => {                    //Creating the data
    const newTask = realm.create("Task", {
      _id: new BSON.ObjectID(),
      name: "go grocery shoppijcdbhjsdbcng",
      status: "Open",
  });  */

console.log("Successfully done");

} catch (err) {
  console.error("Failed to log in", err);


You’re using MongoDB Atlas client – Have you set up your user with the correct rights to allow for read/write into your collection?

Also, it looks like you’re manually adding the “_id” field to your TaskSchema schema and then generating a BSON Object ID in your newTask function however “_id” and value is automatically created for you when you insert a new document.

Try removing those fields from your schema and function, verify user credentials in your Atlas configuration (for now choose readWriteAnyDatabase) and let me know.

This are the rules for User Collection.

And I am been able to insert document via my Android Application but doesnot permit me to insert through my web application .
And in the user collection data is being added as custom user data, so the id being stored in it is the id created while registering the user.

Thank U for your response!

In the Atlas configuration online, you’re looking for settings like this:

:warning: Do not keep the IP address as when you plan to deploy to production.:warning:
The users (or alternatively custom roles), need to be configured on your backend to be permitted to alter databases/collections.

Updated the Database, Still No Change. :frowning:

And your mongoDB url in your app is using the proper connection url and config?

Also, did you see this thread on StackOverflow?

Beyond that I’m stumped. :man_shrugging:t2: Hopefully someone reading the thread will catch something we both overlooked.

1 Like

Yeah, It has been resoved with ur previous solution. Thank u so much for replying

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.