Couchbase Sync Gateway Connection To External Server

I’m trying to have my Sync Gateway (1.2, Ubuntu 14.04) connect to a Couchbase Server (3.0.3, Debian 6 squeeze) on a different virtual machine that is setup behind a router through NAT. I get the errors below (where IP1 is public IP address and IP2 is local internal IP address of external server):

2016-02-09T17:07:30.603-05:00 Enabling logging: [CRUD CRUD+ HTTP HTTP+ Access Cache Changes Changes+] 2016-02-09T17:07:30.603-05:00 ==== Couchbase Sync Gateway/1.2.0(79;9df63a5) ==== 2016-02-09T17:07:30.604-05:00 requestedSoftFDLimit >= currentHardFdLimit (5000 >= 4096) capping at 4096 2016-02-09T17:07:30.604-05:00 Configured process to allow 4096 open file descriptors 2016-02-09T17:07:30.604-05:00 Opening db /default as bucket "groups", pool "default", server <http://debianVM:8091> 2016-02-09T17:07:30.604-05:00 Opening Couchbase database groups on <http://IP1:8091> 2016/02/09 17:07:30 Trying with selected node 0 2016/02/09 17:07:30 Trying with http://10.0.1.53:8091/pools/default/bucketsStreaming/groups 2016/02/09 17:08:00 HTTP request returned error Get http://10.0.1.53:8091/pools/default/bucketsStreaming/groups: dial tcp IP2:8091: i/o timeout 2016-02-09T17:08:00.946-05:00 WARNING: Bucket Updater for bucket groups returned error: Get http://IP2:8091/pools/default/bucketsStreaming/groups: dial tcp IP2:8091: i/o timeout -- base.GetCouchbaseBucket.func1() at bucket.go:469 2016-02-09T17:08:00.946-05:00 WARNING: Lost TAP feed for bucket groups, with error: Get http://IP2:8091/pools/default/bucketsStreaming/groups: dial tcp IP2:8091: i/o timeout -- rest.(*ServerContext)._getOrAddDatabaseFromConfig.func1() at server_context.go:646 2016/02/09 17:08:00 Bucket Updater exited with err Get http://IP2:8091/pools/default/bucketsStreaming/groups: dial tcp IP2:8091: i/o timeout 2016/02/09 17:09:38 HTTP request returned error Put http://IP2:8092/groups/_design/sync_gateway: dial tcp IP2:8092: getsockopt: connection timed out 2016-02-09T17:09:38.181-05:00 WARNING: Error installing Couchbase design doc: Put http://IP2:8092/groups/_design/sync_gateway: dial tcp IP2:8092: getsockopt: connection timed out -- db.installViews() at database.go:532 2016-02-09T17:09:38.181-05:00 FATAL: Error opening database: Put http://IP2:8092/groups/_design/sync_gateway: dial tcp IP2:8092: getsockopt: connection timed out -- rest.RunServer() at config.go:644

Here is my config.json:

{ "log": ["CRUD", "CRUD+", "HTTP", "HTTP+", "Access", "Cache", "Changes", "Changes+"], "interface":":4984", "verbose":true, "adminInterface":":4985", "databases":{ "default":{ "server":"http://IP1:8091", "bucket":"groups", "sync": function(doc, oldDoc) { channel(“all_docs”); } } } }

I routed all of the ports from http://docs.couchbase.com/admin/admin/Install/install-networkPorts.html from IP1 to IP2. What I don’t get is why the server is trying to use the internal address when I give it the external one and if this is the cause of the problem? Or am I even setting this up right? Any help would be appreciated, Thanks.

I know your post is 4 years old, but I’m facing the same problem. sync gateway keeps trying to use the couchbase internal IP, instead of the public one I give in the config file. Couchbase and sync gateway are not in the same network, so it can’t work…
Did you find a solution ?

There have been several enhancements recently to support this type of network architecture, specifically for containerized environments. Both SRV records, and Alternate Address mappings on the Couchbase Server side.

Sync Gateway 2.7.3+ supports Couchbase Alternate Addresses and SRV records, which allow clients to use designated “external” addresses, instead of the internal ones Couchbase Server uses by default.

You can read more about Couchbase Alternate Addresses, and how to set them up here:

Awesome, thanks a lot.