AWS: Set up private connectivity

Private connectivity lets you reach your KiviDB instance from your own AWS network without traffic crossing the public internet. It uses AWS PrivateLink…

Private connectivity lets you reach your KiviDB instance from your own AWS network without traffic crossing the public internet. It uses AWS PrivateLink: KiviDB publishes an endpoint service, and you create an interface VPC endpoint in your own account that connects to it.

Because the connection is made from inside your VPC, you do not need to allow-list any IP addresses. You can also turn off public access entirely once it is working.

What it costs

$25 per instance per month, plus $0.01 per GB of data through the endpoint.

Two things to know about the charge:

  • It is prorated hourly. Enabling it for a few hours costs a few cents, not $25.
  • It continues while the instance is stopped. The network resources stay allocated to you whether the database is running or not, so stopping an instance does not pause this charge. Turning private connectivity off does.

Before you start

You need:

  • A paid instance (Essentials, Pro or Scale). Free-tier instances run on shared infrastructure and cannot use private connectivity.
  • An AWS account of your own, in the same region as your instance. A VPC endpoint cannot cross regions.
  • Permission to create VPC endpoints and security groups in that account.

Step 1 — Enable it on your instance

Private connectivity enabled, showing the endpoint service name to give AWS, and the accounts allowed to connect.

  1. Open your instance, go to Configuration → Network.
  2. Turn on Private connectivity.

The endpoint service takes three to four minutes to build. You will see a notification while it works, and the service name appears when it is ready. You can leave the page; the notification will tell you when it is done.

Until the service exists there is nothing to allow-list against, so the field for AWS accounts stays hidden. It appears once the service name does.

Step 2 — Allow your AWS account

Once the service name appears, add the AWS account that will connect.

In your own account, find its ID:

aws sts get-caller-identity --query Account --output text

Back in Configuration → Network → Private connectivity, add:

arn:aws:iam::<your-account-id>:root

You can also allow a specific role or user instead of the whole account:

arn:aws:iam::<your-account-id>:role/<role-name>
arn:aws:iam::<your-account-id>:user/<user-name>

Nobody can connect until at least one principal is listed. Removing a principal revokes its access.

Step 3 — Find the right availability zone

This is the step people most often get wrong.

Availability zone names are specific to each AWS account: your us-east-1a is usually not the same physical zone as somebody else's. AWS matches them by zone ID instead.

Your instance page shows the zone ID your endpoint service is available in (for example use1-az1). In your own account, find the matching zone name:

aws ec2 describe-availability-zones --region us-east-1 \
  --query 'AvailabilityZones[?ZoneId==`use1-az1`].ZoneName' --output text

Use that zone name when choosing a subnet in the next step.

A high-availability instance publishes its service in every zone its nodes occupy, so you will usually have more than one to choose from.

Step 4 — Create the VPC endpoint

Pick a subnet in the zone from step 3:

aws ec2 describe-subnets --region us-east-1 \
  --filters "Name=availability-zone,Values=<zone-name>" \
  --query 'Subnets[*].[SubnetId,VpcId,CidrBlock]' --output text

Create a security group for the endpoint. This controls what inside your VPC may use it:

aws ec2 create-security-group --region us-east-1 \
  --group-name kividb-endpoint \
  --description "KiviDB private connectivity" \
  --vpc-id <your-vpc-id>

aws ec2 authorize-security-group-ingress --region us-east-1 \
  --group-id <sg-id> --protocol tcp --port 6379-6392 --cidr <your-vpc-cidr>

That range covers every port the endpoint can listen on. Which of them you actually use is up to you -- see Choosing a port below. If you would rather open only what you need, the instance page lists the exact set for your instance.

Now create the endpoint, using the service name from your instance page:

aws ec2 create-vpc-endpoint --region us-east-1 \
  --vpc-id <your-vpc-id> \
  --vpc-endpoint-type Interface \
  --service-name com.amazonaws.vpce.us-east-1.vpce-svc-xxxxxxxxxxxx \
  --subnet-ids <subnet-id> \
  --security-group-ids <sg-id>

You can do the same thing in the console: VPC → Endpoints → Create endpoint → Other endpoint services, then paste the service name and choose Verify service.

Step 5 — Get the hostname and connect

The service name is an identifier, not a hostname. AWS gives you a real DNS name once the endpoint is ready:

aws ec2 describe-vpc-endpoints --region us-east-1 \
  --vpc-endpoint-ids <vpce-id> \
  --query 'VpcEndpoints[0].[State,DnsEntries[0].DnsName]' --output text

Wait for available — it takes a minute or two. The name looks like:

vpce-0abc123def-xyz.vpce-svc-xxxxxxxxxxxx.us-east-1.vpce.amazonaws.com

Connect to that hostname on port 6379 (or 6380 with TLS), using the same username and password as the public endpoint:

redis-cli -h vpce-0abc123def-xyz.vpce-svc-xxxxxxxxxxxx.us-east-1.vpce.amazonaws.com \
  -p 6379 -a "$KIVIDB_PASSWORD" PING

Step 6 — Choosing a port

There is one hostname, but more than one port. The port decides which node you reach — something the public endpoint cannot offer, because it always resolves to the primary.

PortTLS portReaches
63796380The primary. Reads and writes.
63816382Any replica, load balanced across the healthy ones.
63836384Replica 1 specifically.
63856386Replica 2 specifically.

Two more ports are added for each further replica, ascending. Your instance page lists its exact set under Configuration → Network, with a diagram.

Use 6379 unless you have a reason not to. It behaves exactly like the public endpoint.

Use 6381 to send reads to replicas and keep that load off the primary. This is the useful one for read-heavy workloads: connections are spread across every replica that is currently healthy, and a replica that goes away stops receiving traffic without you changing anything.

Use a specific replica port when you want one particular node — benchmarking a single replica, or checking replication lag on each in turn.

A few things worth knowing:

  • Replicas refuse writes. A write sent to a replica port fails with an error rather than being accepted and lost. That is the engine's own behaviour, not something the endpoint adds.
  • A replica port addresses a position, not a machine. If replica 1 is promoted during a failover, its replacement takes the slot and port 6383 follows the slot. The port stays valid; the node behind it may not be the one you started with.
  • Ports exist only for replicas you have. A single-node instance has 6379 and 6380 and nothing else. Adding replicas adds ports.
  • TLS ports exist only when TLS is enabled on the instance.

Step 7 — Optionally block public access

Once private connectivity is working, you can close the public path.

In Configuration → Network, turn on Block public access.

This withdraws your entire IP allow-list, so no client of yours can reach the instance over the internet. Only the AWS accounts you allowed on the endpoint service can connect.

Your allow-list rules are kept, not deleted. Turn the option off and they are reapplied exactly as they were.

Two things worth understanding before you enable it:

  • Test your private connection first. If it is not working, blocking public access will leave you unable to reach the instance from anywhere.
  • KiviDB keeps a management connection. It is used only to operate the service — health monitoring, applying user and permission changes you request, and the in-browser data browser. It cannot be disabled, because those features stop working without it. So blocking public access removes public reach for your clients; it does not remove every network path to the instance. This is set out in section 10.4 of the Terms of Service.

Because of that management connection, the Explorer keeps working after you block public access. That is expected, not a fault.

Turning it off

Turn Private connectivity off in Configuration → Network. The endpoint service and its network resources are removed within a few seconds, and billing stops at that moment.

If Block public access is on, turn that off first. KiviDB will refuse to disable private connectivity while it is the only way in, since doing so would leave the instance unreachable.

Your own VPC endpoint is not deleted by this — it belongs to your account. Delete it yourself once the service is gone:

aws ec2 delete-vpc-endpoints --region us-east-1 --vpc-endpoint-ids <vpce-id>

Troubleshooting

"Name or service not known" — you are connecting to the service name rather than the endpoint DNS name. Go back to step 5.

Endpoint stuck in pending or rejected — the AWS account you are connecting from is probably not on the allowed list. Check step 2, and make sure the account ID matches the one you are actually running in.

Endpoint is available but connections time out — check the security group on your endpoint allows the port from wherever you are connecting, and that you are using 6380 if the instance requires TLS.

If the primary answers but a replica port does not, check that your endpoint's security group covers that port as well. Opening only 6379 is the usual reason a replica port looks dead.

Cannot see the field to add an AWS account — the endpoint service is still being created. Wait for the notification.