> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ClickPipes times out over AWS PrivateLink although the NLB targets are healthy

> A security group on the Network Load Balancer behind a VPC endpoint service can drop ClickPipes traffic while every AWS health check stays green. How to confirm and fix it.

If a ClickPipe that connects through a [VPC endpoint service](https://clickhouse.com/docs/integrations/clickpipes/networking/aws-privatelink.md#vpc-endpoint-service) cannot reach your Kafka brokers or your database, although the reverse private endpoint is ready and all targets of your Network Load Balancer (NLB) are healthy, check whether the NLB has a security group attached. A load balancer with a security group applies its inbound rules to AWS PrivateLink traffic by default, and those rules usually do not match the ClickPipes clients. Turn off the enforcement of inbound rules on PrivateLink traffic for that load balancer.

This applies only to the VPC endpoint service approach, where you run an NLB in front of the data source. The VPC resource and MSK multi-VPC approaches do not use a load balancer of yours.

## Symptoms

* The connection step of the ClickPipe setup fails with a timeout after a long wait.
* The reverse private endpoint has the status `Ready` in the ClickHouse Cloud console.
* In AWS, the endpoint connection is accepted, the endpoint service is available, and every target in the target groups of the NLB is healthy.
* The connection attempts never arrive at the brokers or at the database.

A timeout, as opposed to a refused connection or a TLS error, means that the packets are dropped somewhere on the way.

## Why the health checks stay green

Two documented properties of [security groups for Network Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-security-groups.html) combine here:

* Health checks are subject to the outbound rules of the security group, but not to its inbound rules. A healthy target tells you that the load balancer can reach the target. It tells you nothing about whether client traffic is let in.
* When inbound rules are enforced on PrivateLink traffic, they are evaluated against the private IP address of the client, not against the endpoint network interface. ClickPipes creates the reverse private endpoint in its own VPC, so the client address is not one of yours, and rules that allow your VPC range or your own security groups do not match it.

A security group drops the packets that no rule allows without answering them, so the client waits until its timeout expires.

## Confirm the cause

Check whether the load balancer has security groups and whether it enforces their inbound rules on PrivateLink traffic:

```bash theme={null}
aws elbv2 describe-load-balancers \
    --load-balancer-arns <LOAD_BALANCER_ARN> \
    --query 'LoadBalancers[].[SecurityGroups, EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic]'
```

If the load balancer has no security group, the cause is elsewhere. If it has one and the enforcement is `on`, run the connection step of the ClickPipe again and look at the CloudWatch metrics of the load balancer whose names start with `SecurityGroupBlockedFlowCount_Inbound`. They count the flows that the inbound rules of the load balancer security groups rejected. Blocked traffic does not appear in the other metrics of the load balancer.

AWS reports these [metrics](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-cloudwatch-metrics.html) for the load balancer and its Availability Zones, not for a single client. If the ClickPipe is the only client that opens connections through the load balancer during the test, a value above zero confirms the cause. If other clients use the same load balancer, the rejected flows can be theirs, so a value above zero is a hint and not a proof.

## Fix

Turn off the load balancer option **Enforce inbound rules on PrivateLink traffic**, either in the AWS console or with the AWS CLI:

```bash theme={null}
aws elbv2 set-security-groups \
    --load-balancer-arn <LOAD_BALANCER_ARN> \
    --security-groups <SECURITY_GROUP_IDS> \
    --enforce-security-group-inbound-rules-on-private-link-traffic off
```

The command requires `--security-groups`. Pass the security groups that are attached already (the first command prints them) to leave them unchanged.

If you manage the load balancer as code, the same switch is the `enforce_security_group_inbound_rules_on_private_link_traffic` argument of the load balancer resource in Terraform, and the `EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic` property in CloudFormation. Set it to `off`.

Then repeat the connection step of the ClickPipe. If it still times out, the security group was not the cause, or not the only one: go through the other steps of the setup guides in [Related pages](#related-pages).

The option belongs to the load balancer, not to a single endpoint connection. With `off`, the inbound rules no longer filter any traffic that reaches this load balancer through PrivateLink, whether it comes from ClickPipes or from another consumer of the endpoint service. If other consumers share the load balancer and you rely on the inbound rules for them, consider a separate load balancer and endpoint service for ClickPipes.

The inbound rules of the security group keep applying to traffic that does not arrive through PrivateLink. Access through the endpoint service remains limited by its allowed principals, where you added the ClickPipes account, and by the acceptance of connection requests if the endpoint service requires it.

## Related pages

* [AWS PrivateLink for ClickPipes](https://clickhouse.com/docs/integrations/clickpipes/networking/aws-privatelink.md): the supported approaches and how to create a reverse private endpoint.
* [AWS PrivateLink setup to expose private RDS for ClickPipes](https://clickhouse.com/docs/resources/support-center/knowledge-base/cloud-services/aws-privatelink-setup-for-clickpipes.md) and [AWS PrivateLink VPC endpoint service for MSK cluster](https://clickhouse.com/docs/resources/support-center/knowledge-base/cloud-services/aws-privatelink-vpc-endpoint-service-for-msk-cluster.md): setup guides that include this setting as a step.
* [Custom private DNS](https://clickhouse.com/docs/integrations/clickpipes/networking/aws-privatelink.md#custom-private-dns): for Kafka, the broker host names that the cluster advertises must resolve to the reverse private endpoints. A host name that does not is a separate cause of failed connections.
