Sync Gateway keeps losing connection

I keep losing the connection to the Couchbase server from SG, which is remedied by killing and restarting the docker image.

Logs looks like:

_time=2017-09-18T09:12:35.184+00:00 _level=ERROR _msg= Unable to decode response unexpected EOF
_time=2017-09-18T09:12:35.194+00:00 _level=INFO _msg= Trying with http://<server-ip>:8091/pools/default/bucketsStreaming/mydb
2017-09-18T09:12:35.213Z WARNING: Bucket Updater for bucket mydb returned error: Get http://<server-ip>:8091/pools/default/bucketsStreaming/mydb: dial tcp <server-ip>:8091: getsockopt: connection refused -- base.GetCouchbaseBucket.func1() at bucket.go:404
2017-09-18T09:12:35.213Z WARNING: Lost TAP feed for bucket mydb, with error: Get http://<server-ip>:8091/pools/default/bucketsStreaming/mydb: dial tcp <server-ip>:8091: getsockopt: connection refused -- rest.(*ServerContext)._getOrAddDatabaseFromConfig.func1() at server_context.go:350
_time=2017-09-18T09:12:35.213+00:00 _level=ERROR _msg= Bucket Updater exited with err Get http://<server-ip>:8091/pools/default/bucketsStreaming/mydb: dial tcp <server-ip>:8091: getsockopt: connection refused
_time=2017-09-18T09:14:44.370+00:00 _level=WARN _msg=Finalizing a bucket with active connections.
2017-09-18T09:15:01.064Z HTTP:  #860: GET /mydb/_local/5daae01782bca34822068f63a9691a600e77f7b3
2017-09-18T09:15:01.065Z HTTP: #860:     --> 404 no such database "mydb"  (4.9 ms)

Is there something in my config that might be causing this? I am on an instance with 2GB memory, if that makes a difference?

This is happening about every 30 mins - I keep getting no such database responses then have to restart SG,
This does not bode well for a production environment. Please advise!

I’m also getting a lot of these messages when trying to replicate:

Connection error #1, retrying in 2.0 sec: CBLHTTP[500, "internal server error",

@adamski

Does SG connect to CBS on startup and can you sucessfully call the SG REST API?

Can you supply the SG logs from startup to the connection error, if they are large upload to a GitHub gist (or similar) nad add a link here.

If you see errors in the Couchbase Server logs coinciding wth connection the issues it would be useful to see those. If there are no errors in the CBS logs it would suggest there is a network issue between your docker containers.

Which container runtime are you using?

I am using the Docker image, running both the SG and Couchbase images on the same machine. I upgraded to a larger cloud server, 4GB memory, and it seems to be stable now. There are approximately 140,000 documents each with a small attachment amounting to around 600Mb of data.