Overview
This guide shows how to set up a private link on AWS, connecting a deployed LiveKit agent to a private service in your AWS network over AWS PrivateLink. To learn more, see Private Links.
You expose your service in AWS, then create the private link with the LiveKit CLI.
Prerequisites
Before you begin, make sure you have the following:
- A LiveKit Cloud project linked to the LiveKit CLI.
- A deployed agent in a supported LiveKit region.
- AWS permissions to create endpoint services and approve connection requests.
- An AWS Network Load Balancer (NLB) in front of your service, with healthy targets.
- The TCP port your agent needs to reach. This is the port configured for your NLB listener.
Your NLB must meet the following requirements:
- A listener for the required TCP or TLS port.
- A target group whose targets are all healthy.
- At least two Availability Zones.
- A subnet in the supported Availability Zone for the AWS region of your endpoint service. If your targets are in other Availability Zones, turn on cross-zone load balancing.
- Security groups and network ACLs that permit the expected traffic.
Find the supported zone name
AWS maps Availability Zone names, such as us-east-1a, to Availability Zone IDs differently for each account, so the same name can be a different zone in your account. The supported zone for each region is an ID, such as use1-az1. To find the name that maps to the supported ID for your region, run the following command:
aws ec2 describe-availability-zones \--region <AWS_REGION> \--query "AvailabilityZones[?ZoneId=='<SUPPORTED_AZ_ID>'].ZoneName" \--output text
Step 1: Create an endpoint service
Private Links connect to an AWS endpoint service backed by a Network Load Balancer (NLB).
Sign in to the AWS Console .
Select VPC → PrivateLink and Lattice → Endpoint services.
Select Create endpoint service.
For Endpoint service settings, select Network.
For Available load balancers, select your NLB.
In the Additional settings section, select Acceptance required so connections wait for your approval.
Select Create.
Note the generated service name for the next step. It has the following form:
com.amazonaws.vpce.<AWS_REGION>.vpce-svc-0a1b2c3d4e5f67890On the endpoint service details page, select Allow principals → Allow principals.
In the Principals to add section, copy and paste the ARN of the LiveKit production principal:
arn:aws:iam::266092630715:rootThis authorizes LiveKit to connect to your endpoint service. Don't use a wildcard principal. Adding the LiveKit principal explicitly ensures only authorized LiveKit connections can reach your service.
Select Allow principals.
Create the endpoint service for your NLB, requiring acceptance so connections wait for your approval:
aws ec2 create-vpc-endpoint-service-configuration \--region <AWS_REGION> \--network-load-balancer-arns <NLB_ARN> \--acceptance-requiredThe following example response includes the service ID and the generated service name. Note the
ServiceIdandServiceNamefor the next steps:"ServiceId": "vpce-svc-0a1b2c3d4e5f67890","ServiceName": "com.amazonaws.vpce.us-east-1.vpce-svc-0a1b2c3d4e5f67890"Allow LiveKit to connect by adding the LiveKit production principal:
aws ec2 modify-vpc-endpoint-service-permissions \--region <AWS_REGION> \--service-id <SERVICE_ID> \--add-allowed-principals arn:aws:iam::266092630715:rootThis authorizes LiveKit to connect to your endpoint service. Don't use a wildcard principal. Adding the LiveKit principal explicitly ensures only authorized LiveKit connections can reach your service.
Step 2: Create a private link in LiveKit
Create a link with the LiveKit CLI or the LiveKit Cloud dashboard. For all CLI options, see the private-link create reference.
- Navigate to your project Settings page (https://cloud.livekit.io/projects/p_/settings/private-links) → Private links.
- Select Create new private link.
- Enter a name for the link and complete all other fields:
- The LiveKit region must match the region your agent is deployed to.
- For Cloud provider, select AWS.
- The Port field must match the port configured for your NLB listener.
- For Endpoint, enter the name of the AWS endpoint service you created in the previous step.
- Select Create.
lk --project <LIVEKIT_PROJECT> agent private-link create \--name <LINK_NAME> \--region <LIVEKIT_AGENT_REGION> \--port <TCP_PORT> \--endpoint '<AWS_ENDPOINT_SERVICE_NAME>'
Replace the following:
- <LIVEKIT_PROJECT> Name of the project you want to create the link in.
- <LINK_NAME> Name of the link you want to create.
- <LIVEKIT_AGENT_REGION> Region your LiveKit agent is deployed to.
- <TCP_PORT> Port your agent needs to reach. It must match the port configured for your NLB listener.
- <AWS_ENDPOINT_SERVICE_NAME> Name of the endpoint service you created in the previous step.
LiveKit derives the AWS region from the endpoint service name, so you don't need to pass it separately. Your endpoint service doesn't need to be in the same region as your agent, but using the same region reduces latency. For a list of supported regions, see Supported providers and regions.
For example, the following command creates a private link named customer-redis to an endpoint service in the us-east-1 AWS region:
lk --project production agent private-link create \--name customer-redis \--region us-east \--port 6379 \--endpoint 'com.amazonaws.vpce.us-east-1.vpce-svc-0a1b2c3d4e5f67890'
Save the private link ID and the generated *.link hostname for later use.
Step 3: Approve the connection in AWS
After you create the link, LiveKit requests a connection to your endpoint service. You must approve the request in AWS. The request comes from the LiveKit AWS account, 266092630715.
Wait for the private link status to reach PENDING_APPROVAL before you approve the request in AWS. To view the status, see Confirm the link is healthy.
- In the AWS Console, select VPC → PrivateLink and Lattice → Endpoint services.
- Select your endpoint service and select the Endpoint connections tab.
- Find the pending connection and verify the Owner is
266092630715. - Select the connection, then select Actions → Accept endpoint connection request.
- When prompted, enter accept and select Accept.
List pending connection requests, and verify the Owner is
266092630715:aws ec2 describe-vpc-endpoint-connections \--region <AWS_REGION> \--filters Name=service-id,Values=<SERVICE_ID> \Name=vpc-endpoint-state,Values=pendingAcceptance \--query "VpcEndpointConnections[].{Endpoint:VpcEndpointId,Owner:VpcEndpointOwner}" \--output tableAccept the connection request using the VPC endpoint ID in the Endpoint column from the previous command:
aws ec2 accept-vpc-endpoint-connections \--region <AWS_REGION> \--service-id <SERVICE_ID> \--vpc-endpoint-ids <VPC_ENDPOINT_ID>
For the full CLI reference, see aws ec2 describe-vpc-endpoint-connections and aws ec2 accept-vpc-endpoint-connections .
The connection can take a few minutes to appear while LiveKit provisions resources.
Step 4: Confirm the link is healthy
Check the link status before you connect from your agent. The link moves through PROVISIONING and PENDING_APPROVAL states before reaching HEALTHY. Wait for a HEALTHY status before you connect. For the full list of statuses, see Status values.
Check the link status using the CLI or the LiveKit Cloud dashboard:
View the link status on the Private links page in the Status column.
lk --project <LIVEKIT_PROJECT> agent private-link health-status \--id <PRIVATE_LINK_ID>
Step 5: Test from your agent
The *.link hostname resolves only from a deployed agent, so run any connectivity test from within your agent runtime, not locally.
The following Python code opens 20 connections in a row and fails if any of them don't succeed:
import sockethost = "<GENERATED_HOSTNAME>.link"port = <TCP_PORT>attempts = 20successes = 0for attempt in range(1, attempts + 1):try:# The .link hostname resolves only inside the agent runtime.with socket.create_connection((host, port), timeout=10):successes += 1print(f"success: {attempt}/{attempts}")except Exception as error:print(f"failure: {attempt}/{attempts}: {error}")if successes != attempts:raise RuntimeError(f"Private Links test failed: {successes}/{attempts} succeeded")
After you confirm TCP connectivity, send a real request to your service (for example, a Redis PING or a database query) to verify authentication, TLS, and end-to-end behavior.
Troubleshooting
Use the following sections to diagnose problems when you set up a private link on AWS.
Common issues
The following table includes common issues that can occur when setting up a private link on AWS.
| Issue | Resolution |
|---|---|
| Service not found | Verify the endpoint service name and that you allowed the LiveKit principal. |
| Region unavailable | Contact LiveKit to enable support for that AWS region. |
No endpoint connection appears, or the link stays in PROVISIONING | Confirm the allowed principal and wait a few minutes. If the link still shows PROVISIONING, confirm your NLB has a subnet in the supported Availability Zone. For steps, see Link stays in provisioning. |
| Stuck in pending approval | Accept the endpoint connection request in AWS. |
| Approved but unhealthy | Check NLB target health, listener and target ports, security groups, ACLs, and Availability Zones. |
| Connection timeout | Verify the service listens on the configured port and accepts NLB traffic. |
| DNS failure in the agent | Confirm the agent uses the same LiveKit region as the link and the generated *.link hostname. |
| TLS certificate failure | Configure the client TLS server name, or handle TLS termination at the correct layer. |
| Test fails from your local machine | The *.link hostname resolves only inside a deployed agent. Run connectivity tests from your agent runtime, not locally. |
Link stays in provisioning
A link that stays in the PROVISIONING status with no connection request on the Endpoint connections tab of your endpoint service usually means your endpoint service has no Availability Zone in common with LiveKit. LiveKit reaches your endpoint service through one Availability Zone for each AWS region, listed in Supported providers and regions, so your NLB must include a subnet in that zone.
To fix the problem, do the following:
Find the name of the supported Availability Zone in your account. For example,
use1-az1forus-east-1.Enable the zone on your NLB:
- In the AWS Console, select EC2 → Load Balancers and select your NLB.
- On the Network mapping tab, select Edit subnets.
- Select the supported Availability Zone and a subnet in it. If your VPC doesn't have a subnet in that zone, create one first.
- Select Save changes.
If your targets are in other Availability Zones, turn on cross-zone load balancing so the NLB can reach them from the supported zone:
- In the AWS Console, select EC2 → Load Balancing → Target Groups and select each target group your NLB forwards to.
- On the Attributes tab, select Edit.
- For Cross-zone load balancing, select On, then select Save changes.
If your NLB forwards to an Application Load Balancer, the target group type is
alband the target group has no cross-zone setting of its own. Turn on cross-zone load balancing on the Attributes tab of your NLB instead. To learn more, see Cross-zone load balancing in the AWS documentation.AWS charges for data transfer between Availability Zones when cross-zone load balancing is on. To learn more, see Cross-zone load balancing for target groups in the AWS documentation.
Wait a few minutes for the NLB changes to propagate, then refresh your endpoint service configuration:
aws ec2 modify-vpc-endpoint-service-configuration \--region <AWS_REGION> \--service-id <SERVICE_ID>Run the command once for each endpoint service, not once for each private link. For example, if two private links share one endpoint service, run it once.
Confirm the zones your endpoint service covers:
aws ec2 describe-vpc-endpoint-service-configurations \--region <AWS_REGION> \--service-ids <SERVICE_ID> \--query "ServiceConfigurations[].{Service:ServiceId,NLBs:NetworkLoadBalancerArns,Zones:AvailabilityZones,ZoneIds:AvailabilityZoneIds}" \--output jsonCheck that the supported Availability Zone ID for your region appears in the
ZoneIdslist.
LiveKit retries provisioning automatically, so you don't need to create a new private link. After the retry succeeds, the link moves to PENDING_APPROVAL and the connection request appears on your endpoint service. To approve it, see Approve the connection in AWS.
Additional resources
The following topics provide additional information about Private Links.
Private Links
How Private Links work, supported regions, and limitations.
AWS PrivateLink docs
Learn how to create and configure AWS PrivateLink-based VPC endpoints.
Monitor and manage Private Links
Check link status and manage links programmatically.
Private Links CLI reference
Reference for the private link commands in the LiveKit CLI.
Set up on Azure
Connect through Azure Private Link using a Private Link Service.