Can't get Sync Manager to connect to an existing bucket

Hi, I’m new to Couchbase. I’m using the Couchbase Community Edition, Couchbase Lite iOS for Swift, and I’m trying to setup Sync Gateway to work with an existing bucket. Sync Gateway seems to work in memory mode (walrus), but seems not in default mode.

The Couchbase Admin UI is running at:

Both the node name and bucket name is ‘notes’.

Currently, I’m using this config for the Sync gateway, not sure if it’s right; hence my question:

  "logging": {
    "console": {
      "log_keys": ["*"]
  "databases": {
    "notes": {
      "bucket": "notes",
      "server": "http://localhost:8091",
      "users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } },
      function(doc, oldDoc) {
        if (doc.type == "reject_me") {
	      throw({forbidden : "Rejected document"})
        } else if (doc.type == "bar") {
	  // add "bar" docs to the "important" channel
	} else if (doc.type == "secret") {
          if (!doc.owner) {
            throw({forbidden : "Secret documents must have an owner field"})
	} else {
	    // all other documents just go into all channels listed in the doc["channels"] field

      // Expire documents based on document "expiry" property
    "allow_conflicts": false,
    "revs_limit": 20

I searched a lot on this, tried using users (with passwords) instead of GUEST; didn’t help.


EDIT: Forgot to include the error log:

2018-09-08T16:40:31.880+02:00 [ERR] No logFilePath configured, and --defaultLogFilePath flag is not set. Log files required for product support are not being generated. -- base.(*LoggingConfig).Init() at logging_config.go:40
2018-09-08T16:40:31.880+02:00 ==== Couchbase Sync Gateway/2.1.0(121;a036bd8) ====
2018-09-08T16:40:31.880+02:00 [INF] Console LogKeys: [* HTTP]
2018-09-08T16:40:31.880+02:00 [INF] Console LogLevel: info
2018-09-08T16:40:31.880+02:00 [INF] Log Redaction Level: none
2018-09-08T16:40:31.880+02:00 [INF] Configured process to allow 5000 open file descriptors
2018-09-08T16:40:31.881+02:00 [INF] Opening db /notes as bucket "notes", pool "default", server <http://localhost:8091>
2018-09-08T16:40:31.882+02:00 [INF] GoCBCustomSGTranscoder Opening Couchbase database notes on <http://localhost:8091> as user "notes"
2018-09-08T16:40:31.884+02:00 [INF] Auth: Attempting credential authentication http://localhost:8091?http_idle_conn_timeout=90000&http_max_idle_conns=64000&http_max_idle_conns_per_host=256
2018-09-08T16:40:31.897+02:00 [INF] Error opening bucket: authentication error
2018-09-08T16:40:31.898+02:00 [WRN] Unable to authenticate as user "notes": authentication error -- base.GetBucket() at bucket.go:679
2018-09-08T16:40:31.898+02:00 [WRN] Fatal error connecting to bucket: Fatal error connecting to bucket.  Not retrying -- db.ConnectToBucket.func1() at database.go:160
2018-09-08T16:40:31.898+02:00 [ERR] Error opening database notes: 502  Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port.  Detailed error: Fatal error connecting to bucket -- rest.RunServer() at config.go:902

The users property in the sync gateway config are users for the sync gateway, in other words they’re used for Couchbase lite clients to connect to the sync gateway NOT for the sync gateway to connect to your Couchbase server. To configure the user the sync gateway will use to connect to the Couchbase server set the “username” and “password” property in the sync gateway config (config example in the link below). This is the Couchbase server user you created for the Sync Gateway on step 5 of Configure Couchbase Server: Sync Gateway - Configure Couchbase Server.