Error: parent cluster object has been closed

Getting Error: parent cluster object has been closed with Couchbase Node SDK v3

When on development I would get his error randomly and after restarting the server CB wouldn’t throw this error but now restarting also not a fix for this issue.


Error: parent cluster object has been closed
    at Connection._maybeFwd (E:\project\server\node_modules\couchbase\lib\connection.js:201:13)
    at Connection.query (E:\project\server\node_modules\couchbase\lib\connection.js:305:10)
    at QueryExecutor.query (E:\project\server\node_modules\couchbase\lib\queryexecutor.js:111:16)
    at Cluster.query (E:\project\server\node_modules\couchbase\lib\cluster.js:294:24)
    at _callee6$ (E:\project\server\database\couchbase\/index.js:106:36)
    at tryCatch (E:\project\server\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:63:40)
    at Generator.invoke [as _invoke] (E:\project\server\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:293:22)
    at (E:\project\server\node_modules\@babel\node\node_modules\regenerator-runtime\runtime.js:118:21)
    at asyncGeneratorStep (E:\project\server\database\couchbase\index.js:14:103)
    at _next (E:\project\server\database\couchbase\index.js:16:194)

Couchbase setup

const couchbase = require("couchbase");

const cluster = new couchbase.Cluster("couchbase://localhost/", {
  username: "admin",
  password: "admin123",

const bucket = cluster.bucket("ads");

const collection = bucket.defaultCollection();


This seems to be the server not being ready. This may need to be fixed with some type of loading error, if your API gets this error, please try again or something.

Any additional info can help me to troubleshoot this better. You say restarting the server?

“parent cluster object has been closed” I have found to also mean, “parent cluster object is not ready yet”

Thanks for the response,

I tried restarting the server but that’s not the fix, I tried the couchbase Node SDK example too, and still the “cluster closed” error.

And is there any function to start the cluster? And what the additional info you look forward to troubleshoot?

I’m using node sdk v3


@ericb @chawki sorry, i have same problem, you catch fix. my too use node sdk 3.0.2

1 Like

i work with docker and i use ip for docker container, but i change ip for ‘localhost’

const cluster = new couchbase.Cluster('couchbase://', {
    username: 'user',
    password: '123456',

const cluster = new couchbase.Cluster(‘couchbase://localhost’, {
username: ‘user’,
password: ‘123456’,

works for my

1 Like

So, I have played around with the basic examples many times this week thinking about your issues, it just doesn’t happen for me. I’m wondering if you might be available to do a Zoom call and give me a better look at your project and how it’s set up, exactly how and when you are getting this error, is it only initially a problem and then the error goes away? This seems like an issue that I may not be able to solve with the given info, maybe talking live in person or if you can give us some additional information about your setup or access to the repo or something. Again I’m just not able to recreate the issue on my end. Is this a project in production or just trying out in development? Is it possible that it works on dev env but you’re getting this issue in production?

This is kind of a long shot, but maybe you are facing the same problem I had twice. We are using NestJS + Typescript + Node.js SDK 3.0.4.
Like stated earlier, I have seen a weird issue where all of the suddent the ‘parent cluster object has been closed’ is constantly thrown. Obviously, check the username and password first. But in my case, it was simply a bug in our code, but not in the code that is directly related to couchbase. I don’t know how it ended throwing that error, I assume it has something to do with the asynchronous calls.

As it was some weeks ago, I don’t remember the specifics, but in our case, we were fetching data simultaneously from Couchbase and ElasticSearch ( await Promise.all([…]) ). If something failed in the ElasticSearch query, the error message that was logged to console was ‘parent cluster object has been closed’ from couchase. I don’t know why it behaved like this, but I assume it was because the elasticsearch call failed before the couchbase call returned any data.

Anyways, it’s easy to test if the problem is really related to couchbase or if it is some weird side effect. Just add very minimalistic piece of code to the method(s) in question and return for example static data. Does it work? Good! Then add minimalistic call to the database and still return the static data. Does it still work? If it does, the problem might not be in the couchbase call, but somewhere else in your codebase. Just keep adding the code line-by-line to the method and see if that helps to debug the actual issue.

1 Like