Command to start SG with config file as a service in production (Ubuntu)


I’m on Ubuntu 14.04. SG version is 1.2.

Following this document Configuration using a configuration file I found this command:
$ sync_gateway config.json
This will start SG in the foreground. Is this the right approach for production? I’d like to run SG as a service. After installing SG you can read this in the terminal:

You have successfully installed Couchbase Sync Gateway.

You can find sample sync_gateway configuration files in the /opt/couchbase-sync-gateway/examples folder.

You can control the Couchbase Sync Gateway service by using the following command:

service sync_gateway start

That’s it! Sync Gateway is now running on port 4984. We’ve setup a simple in-memory database
which works great for exploring Sync Gateway’s capabilities. A limited console is available
by opening your browser to http://localhost:4985/_admin/.

The command-line options are:

-adminInterface=":4985": Address to bind admin interface to
-bucket=“sync_gateway”: Name of bucket
-dbname="": Name of CouchDB database (defaults to name of bucket)
-interface=":4984": Address to bind to
-log="": Log keywords, comma separated
-personaOrigin="": Base URL that clients use to connect to the server
-pool=“default”: Name of pool
-pretty=false: Pretty-print JSON responses
-url=“walrus:”: Address of Couchbase server
-verbose=false: Log more info about requests

Running this command service sync_gateway [start | stop] works but the config file is not set. At least this is what I think.

What is the command to start SG with config file as a service in production on Ubuntu 14.04?


If you installed Sync Gateway from a package, then a sync_gateway user account will have been created during installation and a config file copied there.

This is usually located in /home/sync_gateway/sync_gateway.json

To edit the config file first switch user to sync_gateway to preserve file access.

$ sudo su - sync_gateway
Once you have edited the config, restart the sync_gateway service or restart the server/container.

Hi andy!

I followed your instructions and it seems to work. Would you know if there is a command to print out the config file which is in use at the moment? Just to be 100% certain.


You can retrieve the config for an individual DB with the following curl command:

curl -X GET http://host:4985/dbname/_config
1 Like