Unable to create rules for my existing Atlas collections

Hello. I seem to be having this same issue six months later:

In this case I have already created and populated collections on Atlas and now I am trying to get started working with them on the front-end. This is my first foray into Realm.

I will try disconnecting and reconnecting as @Ian_Ward suggested above and will post an update if that works, but wanted to point out that this issue may not have been fixed yet.

I was still unable to create rules for my existing Atlas collections after unlinking and relinking. I tried two methods of linking the data source:

1) Automatically by creating a new Realm app

When creating a new Realm app, I am prompted to select the existing cluster as the data source, and a link with the service name mongodb-atlas is automatically configured for me. From the Realm UI, this data source shows my existing collections from Atlas. However, when I attempt to create a rule for any of these collections, I get the same error:

Failed to add rule: error processing request

I also get this error when I attempt to create rules for a new (non-existent) collection on this data source, as @Jay appears to have been doing in the original post above.

2) Manually using the “Link a Data Sources” tool under the “Manage” section of the side bar

Although I can select my Atlas cluster from this tool, once it is linked it does not find any of my existing collections. On this service, however, I can create a new rule on a “new” database and collection - i.e. I can successfully make a rule for a collection that doesn’t exist on a database that doesn’t exist on the Atlas cluster. Not really sure what to make of this.


To my knowledge (I am not a MongoDB employee), the current version of Realm has still not released rule based permissions. This is why you see the banner

Sync is in Beta: Permissions for this synced collection are set 
on the synced cluster. 

Developers are urged to use Sync permissions instead, which is documented here


These can be a little daunting to understand right out of the gate, and took me several days to fully digest. I did however write a medium article that tries to explain how to implement them.

I hope this helps

Richard Krueger

Update: I was able to create rules for an existing collection by using the Realm CLI.

  • Install the Realm CLI.

  • Log into the Realm app using realm-cli login. (Requires creating an API key for the app).

  • Create a local application configuration folder for the app. In particular I needed to figure out where to put my rules config for the collection in question, and what to put in it. When creating a new rule set, do not include the "id" field. The ID will be created for you when you push the rules up with realm-cli import.

    I started with a bare minimum rule config that looked like this:

    // <application-name>/services/<service-name>/rules/<database-name>.<collection-name>.json
      "collection": "<collection-name>",
      "database": "<database-name>",
      "roles": [
              "name": "default",
              "apply_when": {},
              "insert": true,
              "delete": true,
              "search": true,
              "additional_fields": {}
      "schema": {}
  • Push the application configuration up using realm-cli import.

This seems to be enough for me to get unstuck and move on with my work. However I don’t know if it is appropriate to close this issue because the problem with the Realm web UI remains. I am still unable to create new rules for my collections using those tools, which are much more convenient and expedient for the kind of work I am doing right now.

Thanks @Richard_Krueger. It looks like I was able to accomplish what I was trying to accomplish. I just posted an update on this thread which I assume will appear as soon as the mods approve it. Still haven’t delved into Sync. There is so much to learn! But as far as I can tell so far, creating these Realm access rules is critical to any aspirations to access Atlas data from the browser.

One more update.

I suspect the problem was that I was over my storage limit on the free tier of Atlas.

One of my existing collections was very large. When I finished uploading it, I checked the metrics and was under the impression I was still under the 512MB storage limit for the free tier, which I am using to explore the system. I either misread the numbers or some kind of further processing occurred on that data (e.g. generating indexes maybe), as today I see that I am a little bit over the quota. It seems that MongoDB blocks most interactions with the system when you are over your limit (e.g. GraphQL queries return an error stating as much). After deleting the large collection in order to continue with my work, I find I am now able to create rules on the remaining existing collections using the Realm UI.

This is not the rigorous proof of a solution I would hope for but suffice to say everything seems to be working normally now.


Yea, the free tier is really just there for you to experiment with - it’s pretty easy to blow past the minimum memory requirement once you get serious.

I have used realm-cli to set the rules as well. One thing to remember is that if you have dev mode turned on, even if you set the rules through the cli, they won’t be respected. In order for the sync rules to work, you have to have dev mode turned off, which is what you want for production.

Richard Krueger

1 Like

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