Couchbase Keyspace issue!

I am currently working on syncing documents using Sync Gateway and Postman, but I am encountering an issue with setting up the keyspace correctly. I have followed the documentation available at Public REST API | Couchbase Docs.

The structure of my data is as follows:

  • Bucket name: traq
  • Scope: master
  • Collection: project

According to the documentation, I tried using the following URL to sync documents with a specific keyspace: http://localhost:4984/traq.master.user/

However, when attempting to use this URL, I receive the following error message:
“error”: “not_found”,
“reason”: “keyspace traq.master.user not found”
I have verified that the “traq” bucket, “master” scope, and “user” collection do exist in my Couchbase Server. The documents are syncing with the default scope successfully, but I am unable to sync them with the specified keyspace.

Unfortunately, the documentation does not provide any examples or clear guidance on how to resolve this issue, making it quite confusing for me to troubleshoot.

If anyone has experience with Sync Gateway and could shed some light on what might be causing this problem or provide a step-by-step guide on how to set up the keyspace correctly, I would greatly appreciate your assistance.

What do you have in your Sync Gateway configuration? The first component of the URL keyspace path is the Sync Gateway database name, and not necessarily the bucket name (unless you’ve named them the same). Alternatively, how did you set up the Sync Gateway database (with the admin API).

Even I have this problem. Here is my configuration file.

  "bucket": "main",
  "name": "main-content",
  "guest": {
    "disabled": true
  "import_docs": true,
  "num_index_replicas": 0,
  "enable_shared_bucket_access": true,
  "scopes": {
    "_default": {
      "collections": {
        "content": {
          "sync": `
            function(doc, oldDoc, meta) {
          "import_filter": `
            function(doc) {
              return true;

The step described in Get a document using the API is returning the error the OP has posted.

here is the curl command and its reponse

curl --location --request GET 'http://localhost:4985/main-content/000345a3-3042-428d-8ee0-3782c73cb41f' \
      -H 'Authorization: Basic <auth-token>'

{"error":"not_found","reason":"keyspace main-content not found"}

I’m using sync-gateway:3.1.1-community with server:community-7.2.2

Your Keyspace/URL should look like:

/main-content._default.content/ since you’re defining the content collection inside the _default scope on the main-content database inside your config.

1 Like

Oh, the target endpoint includes the scope and collection name? I did not know that. Let me try and get back.

This worked. Thanks.

Any idea what the end point should be for data sync using remote sync-gateway when using custom collections?

For the same configuration posted above, I have been using ws://localhost:4984/main-content and it is not working. I have tried ws://localhost:4984 and ws://localhost:4984/main-content._default.content as well but no luck.

If you have any other inputs for that issue, i would appreciate that.

Just the database name main-content (collections are defined/filtered/set elsewhere in the CBL replicator config)

If you could elaborate on “not working” with whatever error messages you’re seeing that’d help.

@bbrks By not working, I mean that pull replication fails to fetch any documents from the custom collection. I have a log file which cannot be attached here because it goes above the limit of characters. Can I DM/email you?

I am basically stuck in this for 3 days now. So, any guidance is super appreciated.

I’m guessing this is the same issue as the one over in your other post: Sync Gateway Data Synchronization Issue with Custom Collection ?
If so, let’s keep the discussion focussed there instead of hijacking this post, thanks!

Yes, I was referring to that problem. We can chat in that thread.

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