Found the solution.
The problem was Sync Gateway service was going to start before Couchbase Server was started. To solve this issue edit the couchbase_init.d file as following:
$ nano /opt/couchbase/etc/couchbase_init.d
look for start() {
section and change it from this:
errcode=$?
return $errcode
to this:
errcode=$?
sleep 20
initctl emit couchbase-server-started
return $errcode
Then edit the sync-gateway.conf file
$ nano /etc/init/sync_gateway.conf
and change this line:
start on runlevel [2345]
to this:
start on runlevel [2345] and couchbase-server-started
That will start the sync-gateway service after Couchbase server is started.