Couchbase with AWS Lambda Issue

The following is the version that is installed in the EC2 linux

Addresses: (int)
Address Family: IPv4
Encryption: Off
OS: x86_64-unknown-linux-gnu
Version: Enterprise Edition 6.6.0 build 7909

We have attached the elastic public IP to the above instance , From the browser we are able to access the couchbase server .

When we try to connect from AWS lambda nodejs - 12.x we are getting the time out error.

The following is the code from nodejs

The couchbase version is 3.0.6

in the below we tried by passing port and with out port too.

const couchbase = require(‘couchbase’);
var cluster = new couchbase.Cluster(‘couchbase://’, {
username: ‘admin’,
password: ‘@poms2020!’

var bucket = cluster.bucket(‘poms’);

var collection = bucket.defaultCollection();

var document1= {“id”:“test”};
//const UUID = require(“uuid”);
var key=‘1’;
try {
const insertResult = await collection.insert(key, document1,
{timeout:10000} // 10 seconds
}catch (error) {


Can you please tell us if we doing any thing incorrect?

As soon as you start using VIPs or DNAT, then things get problematic. A little background. When you create Couchbase nodes, you name them with a DNS name or an IP address. These nodes are then advertised to the client (service discovery). In your example, your node could be called When the client connects to the public VIP, it does through a DNAT and hits the node, that then responds with a list of all node host names. The problem here is that is a bogon, and you cannot route to it across the internet.

Now, what you can do is override the advertised host names and replace them with a public VIP, load balancer, stable DNS name that is addressable from you client as per In this situation for node you would add an alternative address of When the client gets the advertisement, it will see the alternative address and use that instead when talking to the node.

Of course, this may still not fix it, but it’s the obvious thing to check! Let me know how you get on.

Hi Simon, checked it still unable to connect. Does the couchbase work with remote server ?

Absolutely, it’s how Couchbase Cloud works.

I guess you’re going to have to do some network debug. You can probably write some form of lambda to:

  • Open a TCP socket to the server (routing/firewall problem)
  • Run an API query /pools/default/nodeServices (authentication problem)
  • For all the hosts returned by that query, open a TCP socket (routing/firewall/discovery problems)