Getting a timeout error when trying to upsert

I am using a newer Couchbase server hosted on cloud server. I can connect to a cluster and bucket but every time I try to do upsert into the bucket, I get a timeout error. I have tried to use timeoutConfig to timeout for around 60 seconds, which leads it to keep trying but fails and gives the timeout error. Is there a suggestion to try something else or debug further?

Here is my code:

package com;

import com.couchbase.client.core.env.*;

import java.time.Duration;

public class HelloCouchbaseJava {
    public static void main(String[] args) {
        String bucketName = "test";
        String username = "test ";
        String password = "test";
        String connectionString = "couchbase://";

        ClusterEnvironment env = ClusterEnvironment.builder()

        ClusterOptions clusterOptions = ClusterOptions.clusterOptions(username, password);
        Cluster cluster = Cluster.connect(connectionString, clusterOptions);
        Bucket bucket = cluster.bucket(bucketName);

        Collection collection = bucket.defaultCollection();
        MutationResult upsertResult = collection.upsert(
                JsonObject.create().put("name", "mike")

        GetResult getResult = collection.get("my-document");
        String name = getResult.contentAsObject().getString("name");
        System.out.println(name); // name == "mike"

        QueryResult result = cluster.query("select \"Hello World\" as greeting");

Error is this:
TimeoutException: Did not observe any item or terminal signal within 10000ms in 'source(MonoDefer)' (and no fallback has been configured)

Hi @couchbasec ,

“Connecting” to a cluster/bucket is something that happens in the background. If there are network or configuration issues, they might not surface until later. If you want to surface them immediately, you can call cluster.waitUntilReady() or bucket.waitUntilReady() right after connecting or opening the bucket. See Waiting for Bootstrap Completion.

Some quick things to check:

  • Make sure the credentials are correct, and the user has permission to access the bucket.

  • Make sure the required ports are exposed.

  • If the server requires TLS (hosted Couchbase Cloud instances require TLS) you’ll need to configure the cluster environment to enable TLS and specify the certificate to trust. See Secure Connections.

  • If the server is on a different network than the client, the server must be configured to advertise Alternate Addresses.

The client-side log might have some hints about why the operation is timing out. Can you share more of the log?


In addition to @david.nault 's suggestions, one more thing to check if you’re on Couchbase Cloud, is that you’ve whitelisted your IP (or all IPs) in the Cloud UI.