Authentication Error when trying to connect Sync Gateway to Couchbase Server

I am new to Couchbase and databases in general, I’ve been working through the documentation to set up a CB server and a sync gateway so that I can eventually try out Couchbase Lite. I managed to run sync gateway using the ‘walrus:’ setup without any issues and I’ve added a bucket to the server called ‘mobile_bucket’. However I am running into this problem when I start Sync Gateway while trying to connect to my locally hosted Couchbase Server

MacOS 10.12.6
Couchbase Server 5.0
Sync Gateway 1.5

My sync gateway config:

    "log": ["*"],
    "databases": {
        "db": {
            "server": "",
            "bucket": "mobile_bucket",
            "users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } }

Terminal Output:

Braydens-MacBook-Pro:bin brayden$ ./sync_gateway sync-gateway-config2.json
2017-10-26T10:26:45.884-04:00 Enabling logging: [*]
2017-10-26T10:26:45.884-04:00 ==== Couchbase Sync Gateway/1.5.0(494;5b6b5b9) ====
2017-10-26T10:26:45.884-04:00 Configured process to allow 5000 open file descriptors
2017-10-26T10:26:45.884-04:00 Opening db /db as bucket "mobile_bucket", pool "default", server <>
2017-10-26T10:26:45.884-04:00 GoCBCustomSGTranscoder Opening Couchbase database mobile_bucket on <> as user "mobile_bucket"
2017-10-26T10:26:45.886-04:00 WARNING: Error opening bucket: mobile_bucket.  Error: authentication error -- base.GetCouchbaseBucketGoCB() at bucket_gocb.go:117
2017-10-26T10:26:45.886-04:00 Debug: RetryLoop retrying Attempt to connect to bucket : mobile_bucket after 5 ms.

… continued …

2017-10-26T10:15:37.235-04:00 GoCBCustomSGTranscoder Opening Couchbase database mobile_bucket on <> as user "mobile_bucket"
2017-10-26T10:15:37.237-04:00 WARNING: Error opening bucket: mobile_bucket.  Error: authentication error -- base.GetCouchbaseBucketGoCB() at bucket_gocb.go:117
2017-10-26T10:15:37.237-04:00 WARNING: RetryLoop for Attempt to connect to bucket : mobile_bucket giving up after 14 attempts -- base.RetryLoop() at util.go:293
2017-10-26T10:15:37.237-04:00 FATAL: Error opening database: 502  Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port.  Detailed error: authentication error -- rest.RunServer() at config.go:761

you should add
username and password in db object.

With Role Based Access Control (RBAC) newly introduced in Couchbase Server 5.0, you’ll need to create a new user with authorized access to the bucket. Choose the Security > Add User option in the Couchbase Server Admin and select the Bucket Full Access and Read Only Admin roles.
Start Sync Gateway with the following configuration file.

“databases”: {
“db”: {
“bucket”: “my-bucket”,
> “username”: “my-user”,
> “password”: “my-password”,
“server”: “http://localhost:8091”,
“enable_shared_bucket_access”: true,
“import_docs”: “continuous”
There are two properties to keep in mind. The enable_shared_bucket_access property is used to disable the default behaviour. And the import_docs property to specify that this Sync Gateway node should perform import processing of incoming documents. Note that in a clustered environment, only 1 node should use the import_docs property.

1 Like

Thank you for the information, I have it working now

what does only one node should use import_docs ?
can you elobarate more !

That’s referring to the number of Sync Gateway nodes. When Sync Gateway “imports” docs from Couchbase Server, it adds the meta data needed for Couchbase Mobile. You only want one SG instance doing that.

hi @hod.greeley,

If I have 3 nodes sync gateway, one node for import on 4984 port, and two nodes for non-import on 4986 port. how the couchbase lite replicator to configure? which node will lite connect for sync data? can lite automatic switch node with balance?

Best regards


This is enough of a different question that you probably want to open it as its own thread. But to answer, this is an unusual configuration. Maybe you can clarify why you’re doing it this way?

I’m going to assume the previous discussion was confusing. So, when we talk about having only one node of Sync Gateway import from Couchbase Server, that’s SG <- CBS. What you’re indicating is that you’ve opened up different ports for the Couchbase Lite to SG sync. That’s probably not what you want.