How to Setup Sync Gateway on Ubuntu/DigitalOcean

I recently set up Couchbase Sync Gateway on DigitalOcean. This is a note about setting Couchbase Sync Gateway with Couchbase Server on Ubuntu/DigitalOcean.

Step 1: Create Virtual Server on DigitalOcean

Before Step 1, please sign up DigitalOcean. DigitalOcean is super user friendly hosting. To create the virtual server, simply follow the tutorial How To Create Your First DigitalOcean Droplet Virtual Server.


  • Size: $5/mo is good enough for development/experiment
  • Droplet Region: Select closest region from my actual location. Response times from New York and San Francisco are different.
  • Droplet Image: Select Ubuntu 14.04 x64. Couchbase Server 3.0.x does not support 32bit.

Step 2: Setting up Ubuntu 14.04

For setting up Ubuntu such as create new user or configure firewall, I just followed the Tutorial Series New Ubuntu 14.04 Server Checklist.


  • Basic Firewall: Couchbase server admin UI uses port 8091 as default, and Couchbase Sync Gateway uses 4984 for replication and 4985 for admin UI. I recommend to open these three ports (4984, 4985 and 8091) in addition to SSH port 22.

My sample configuration for opening ports

$ sudo ufw show added
Added user rules (see 'ufw status' for running firewall):
ufw allow 22
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 8091/tcp
ufw allow 4984/tcp
ufw allow 4985/tcp

Step 3: Install Couchbase Server 3.0.2

1. Download Couchbase Server
Couchbase Server is downloadable from Couchbase Download. Currently (03/21/2015) Couchbase Server 3.0.2 is only for Enterprise Edition only. Go to Version 3.0.1. Select 64-bit and Community Edition, then grab download URL from Download button for Ubuntu 12.04. By using wget command, download installation package to Ubuntu server. See following command.

$ wget

2. Install Couchbase Server
Install the package using the dpkg command as a privileged user under sudo.

$ sudo dpkg -i couchbase-server-community_3.0.1-ubuntu12.04_amd64.deb

3. Confirm installation
Open the URL, http://<IP address of Ubuntu server>:8091/, from your favorite browser. You can see welcome page of Couchbase Server

4. Setup Couchbase Server
As a development server, I just use all default settings. For “Per Server RAM Quota:”, I set half of hosting server’s memory. For my case, it is 256MB. Although it is lower than recommended size, I think it is good enough for development.

5. Create Data Bucket for Sync Gateway
Select “Data Buckets” Menu on the top bar. Before creating new bucket for Sync Gateway, I deleted “default” bucket because no plan to use it. After that,  click “Create New Data Bucket” button. For Bucket Name, I chose “sync_gateway”. And set 256MB for “Per Node RAM Quota”.

Step 4: Install Couchbase Sync Gateway

1. Download Couchbase Sync Gateway
Couchbase Sync Gateway is also downloadable from Couchbase Download Link. You can find download link for Sync Gateway at middle of page. Current latest version of Sync Gateway is 1.0.3 (1.0.4 should be officially released soon). Select 64bit and Community Edition. For my case, if I download Sync Gateway installation package using wget and tried to install package, it fails. So I downloaded Sync Gateway installation package locally through my browser, then scp it from local computer to Ubuntu server.

2. Install Couchbase Sync Gateway
Install the package using the dpkg command as a privileged user under sudo.

$ sudo dpkg -i couchbase-sync-gateway-community_1.0.3_x86_64.deb

3. Sync Gateway configuration

The link is a default sync gateway configuration. The default setting does not allow GUEST user to access.  So I created following configuration file. The difference is Authorizing Users setting.

         "users": {"GUEST": {"disabled": false, "all_channels": ["*"], "admin_channels": ["*"]}},
         "sync":`function(doc) {channel(doc.channels);}`

4. Start Sync Gateway

Following is how to start sync gateway

/opt/couchbase-sync-gateway/bin/sync_gateway ./config.json

Output just after started sync gateway

$ /opt/couchbase-sync-gateway/bin/sync_gateway ./config.json 
20:03:14.925870 Enabling logging: [REST]
20:03:14.926411 ==== Couchbase Sync Gateway/1.0.3(81;fa9a6e7) ====
20:03:14.926520 Opening db /sync_gateway as bucket "sync_gateway", pool "default", server <http://localhost:8091>
20:03:14.926674 Opening Couchbase database sync_gateway on <http://localhost:8091>
20:03:15.182813     Reset guest user to config
20:03:15.182843 Starting admin server on :4985
20:03:15.192678 Starting server on :4984 ...

5. Confirm Sync Gateway Running

To confirm replication port, open the URL, http://<IP address of Ubuntu server>:4984/, from your favorite browser. You can see welcome page of Couchbase Sync Gateway. See following.

   "vendor":{"name":"Couchbase Sync Gateway","version":1},
   "version":"Couchbase Sync Gateway/1.0.3(81;fa9a6e7)"

To confirm admin port, pen the URL, http://<IP address of Ubuntu server>:4985/_admin/, from your favorite browser. You can see admin UI of Sync Gateway.

Next Step:

I will write about How to sync with Couchbase Lite.