#### Cloud Agents

# Private connectivity

Grok Build supports private network connectivity for Enterprise teams that need Grok Build to work with systems that are not reachable from the public internet. This includes self-hosted GitHub Enterprise Server, GitLab Enterprise, Bitbucket Data Center, Artifactory, Nexus, private source control APIs, and webhook traffic from those systems back to Grok Build.

The same private connectivity setup is used across Grok Build services that need access to your source control system, including [Cloud Agents](/build/agents-window/cloud-agent), [Bugbot](/build/agents-window/bugbot), [Security Review](/build/agents-window/security-review), [Vulnerability Remediation](/build/agents-window/vulnerability-remediation), and Grok Build backend services.

> [!NOTE]
>
> To set up private connectivity, contact [support@x.ai](mailto:support@x.ai) or your Grok Build sales representative.

## Supported options

| Option | Best for | Cloud provider | Status |
| :--- | :--- | :--- | :--- |
| AWS PrivateLink | Private connectivity between Grok Build and your Git provider or package registry, including webhook traffic back to Grok Build | AWS | Supported |
| Cloudflare Tunnel | Grok Build accessing a private origin when AWS PrivateLink is not practical | Any environment that can run `cloudflared` | Supported |

## How to choose

Use AWS PrivateLink when your private Git provider or package registry is in AWS or can sit behind an AWS Network Load Balancer. This is the preferred path for self-hosted GitHub Enterprise Server and GitLab Enterprise.

AWS PrivateLink can cover two traffic directions:

* Grok Build accessing your private Git provider to clone repositories and call Git APIs.
* Your Git provider sending webhooks or callbacks to Grok Build over `api2.cursor.sh` without public internet egress.

Use Cloudflare Tunnel when you cannot publish an AWS endpoint service or when you need a deployment model that only requires an outbound tunnel from your network.

If your team requires Google Private Service Connect (PSC), contact Grok Build. Grok Build doesn't offer a customer-facing PSC service.

## Prerequisites

Before starting, make sure you have:

* A Grok Build Enterprise workspace
* A self-hosted GitHub Enterprise Server, GitLab Enterprise, Bitbucket Data Center, or private package registry (such as Artifactory or Nexus) reachable over HTTPS on port 443
* A publicly trusted TLS certificate for the Git or registry hostname
* DNS ownership for that hostname
* AWS permissions to create endpoint services or interface VPC endpoints, if using AWS PrivateLink
* Permission to run `cloudflared`, if using Cloudflare Tunnel

Grok Build does not support self-signed certificates, unencrypted connections, SSH, custom ports, or IPv6-only endpoint services for these private connectivity paths.

> [!NOTE]
>
> If you run a proxy in front of GitHub Enterprise Server, make sure it allows Grok Build's GitHub App integration to use authenticated GitHub REST and GraphQL APIs.

## AWS PrivateLink

AWS PrivateLink supports private traffic in either direction between Grok Build and your Git provider or package registry. You may need one direction or both, depending on your network policy.

### Direction 1: Grok Build to your Git provider or package registry

Use this option when Grok Build needs to clone repositories, call Git APIs, or reach a private package registry such as Artifactory or Nexus.

#### 1. Create an AWS endpoint service

Create a Network Load Balancer in front of your Git provider or package registry HTTPS endpoint. Publish that load balancer as an AWS VPC endpoint service.

Send Grok Build:

* Endpoint service name, for example `com.amazonaws.vpce.us-east-1.vpce-svc-0123456789abcdef0`
* AWS region
* Git or registry hostname, for example `github.example.com` or `artifactory.example.com`
* Whether your endpoint service has AWS-managed private DNS enabled
* Whether your Network Load Balancer preserves client IPs or your backend filters source IPs

If your endpoint service is outside `us-east-1`, enable cross-region access on the endpoint service.

#### 2. Allow Grok Build's AWS principal

Grok Build will provide the AWS principal to add to your endpoint service allowed principals. Add the exact principal Grok Build provides:

```text
arn:aws:iam::<cursor-aws-account-id>:root
```

Grok Build cannot create its interface endpoint until this principal is allowed. If the principal is missing or does not match exactly, AWS returns `InvalidServiceName`.

If your load balancer preserves client IPs, or if your backend filters source IPs, allow these Grok Build PrivateLink subnet CIDRs:

```text
10.2.8.0/21
10.2.24.0/21
10.2.40.0/21
```

#### 3. Accept the endpoint connection

After Grok Build creates the interface endpoint, accept the endpoint connection in your AWS account if your endpoint service requires manual acceptance.

#### 4. Configure DNS

If your endpoint service exposes AWS-managed private DNS for your Git or registry hostname, Grok Build enables private DNS on its interface endpoint.

If your endpoint service does not expose private DNS, Grok Build creates private DNS on its side and maps that hostname to the endpoint DNS name.

Use the same hostname in Grok Build that appears on the TLS certificate and in DNS.

### Direction 2: Your Git provider to `api2.cursor.sh`

Use this option when your GitHub Enterprise Server or GitLab Enterprise host cannot reach the public internet but still needs to send webhooks or callbacks to Grok Build.

Grok Build publishes an AWS PrivateLink endpoint service for `api2.cursor.sh`. You create an interface VPC endpoint in your AWS account and enable private DNS so `api2.cursor.sh` resolves to private endpoint IPs from your Git provider network.

#### Endpoint service details

Grok Build will confirm your AWS principal is allowlisted before you create the endpoint.

| Field | Value |
| :--- | :--- |
| Service name | `com.amazonaws.vpce.us-east-1.vpce-svc-054b15427d4bea2b7` |
| Service ID | `vpce-svc-054b15427d4bea2b7` |
| Home region | `us-east-1` |
| Supported consumer regions | `us-east-1`, `us-east-2`, `us-west-2`, `eu-central-1`, `eu-west-1`, `ap-southeast-2` |
| IP address types | IPv4 only |
| Private DNS name | `api2.cursor.sh` |

#### Mode 1: AWS-managed private DNS

This is the recommended mode. Set `private_dns_enabled = true`.

```text
resource "aws_vpc_endpoint" "cursor_api2" {
  vpc_id              = aws_vpc.app.id
  service_name        = "com.amazonaws.vpce.us-east-1.vpce-svc-054b15427d4bea2b7"
  service_region      = "us-east-1"
  vpc_endpoint_type   = "Interface"
  subnet_ids          = [for subnet in aws_subnet.app_private : subnet.id]
  private_dns_enabled = true
  security_group_ids  = [aws_security_group.cursor_api2_endpoint.id]
}
```

AWS associates your VPC with the managed private hosted zone for `api2.cursor.sh`. Inside the VPC, `api2.cursor.sh` resolves to the endpoint ENI IPs. No Route 53 record is required.

#### Mode 2: Customer-managed private hosted zone

Use this mode if you want to own the DNS record. Set `private_dns_enabled = false`, then create a private hosted zone for `api2.cursor.sh` scoped to the consumer VPC.

```text
resource "aws_vpc_endpoint" "cursor_api2" {
  vpc_id              = aws_vpc.app.id
  service_name        = "com.amazonaws.vpce.us-east-1.vpce-svc-054b15427d4bea2b7"
  service_region      = "us-east-1"
  vpc_endpoint_type   = "Interface"
  subnet_ids          = [for subnet in aws_subnet.app_private : subnet.id]
  private_dns_enabled = false
  security_group_ids  = [aws_security_group.cursor_api2_endpoint.id]
}

resource "aws_route53_zone" "cursor_api2" {
  name    = "api2.cursor.sh"
  comment = "Customer-managed PHZ for api2.cursor.sh scoped to the app VPC."

  vpc {
    vpc_id = aws_vpc.app.id
  }
}

resource "aws_route53_record" "cursor_api2_a" {
  zone_id = aws_route53_zone.cursor_api2.zone_id
  name    = "api2.cursor.sh"
  type    = "A"

  alias {
    name                   = aws_vpc_endpoint.cursor_api2.dns_entry[0].dns_name
    zone_id                = aws_vpc_endpoint.cursor_api2.dns_entry[0].hosted_zone_id
    evaluate_target_health = false
  }
}
```

If GitHub Enterprise Server or GitLab Enterprise uses DNS outside the endpoint VPC, forward `api2.cursor.sh` queries to the VPC resolver or create an equivalent private DNS override. Do not create a public DNS override.

## Cloudflare tunnel

Use Cloudflare Tunnel when AWS PrivateLink is not a fit.

Grok Build creates the tunnel and shares:

* A public hostname under Grok Build-controlled DNS
* A tunnel token through a secure 1Password share
* A sample `cloudflared` configuration

Your network runs `cloudflared` and opens outbound connections to Cloudflare. No inbound firewall rule is required.

Example `cloudflared` configuration:

```yaml
ingress:
  - hostname: <cursor-provided-hostname>
    service: https://<your-internal-service>:443
  - service: http_status:404
```

Example run command:

```bash
docker run -d --restart=always --name cloudflared \
  -v /path/to/config.yml:/etc/cloudflared/config.yml \
  cloudflare/cloudflared:latest \
  tunnel --config /etc/cloudflared/config.yml \
  run --token <TUNNEL_TOKEN>
```

Keep the tunnel token secret. Do not send it through email or chat.

### Private network tunnels for MCP servers

To let Cloud Agents reach [MCP](/build/agents-window/mcp) servers on your private network, admins can create a Cloudflare tunnel themselves from **Integrations** → **Private Network Tunnels** in the [dashboard](https://grok.com/dashboard/integrations).

1. Click **Add Tunnel**.
2. For each MCP host, enter its **Private Hostname** and **Service URL**. Click **Add Host** to add more.
3. Copy the **Connector Token**. It's shown only once.
4. Run `cloudflared` with the token on a machine in your network, as a service, in the foreground, or with Docker. For example: `cloudflared tunnel run --token <TOKEN>`.

**Rotate Token** issues a new connector token. **Delete Tunnel** removes the tunnel, and the MCP hosts behind it stop working.

## Complete the source control connection

After private networking is configured, complete the source control setup in Grok Build:

* For GitHub Enterprise Server, follow the [GitHub integration setup](/build/agents-window/integrations/github#setup).
* For GitLab Enterprise, follow the [GitLab integration setup](/build/agents-window/integrations/gitlab#setup).
* For Bitbucket Data Center, follow the [Bitbucket integration setup](/build/agents-window/integrations/bitbucket#setup).
* Use the same hostname that is covered by your TLS certificate and private DNS configuration.
* If a proxy sits in front of your Git provider, make sure it allows the authenticated API traffic described in [Prerequisites](#prerequisites).

Grok Build uses the connected source control integration for Cloud Agents, Bugbot, Security Agents, and other Grok Build services that need repository access.

### Check the private webhook path

If your Git provider sends webhooks to Grok Build through the `api2.cursor.sh` PrivateLink path, run these checks from the same network path used by GitHub Enterprise Server or GitLab Enterprise:

```bash
getent hosts api2.cursor.sh
# or, if dig is available
dig +short api2.cursor.sh
curl -sS https://api2.cursor.sh/
```

Every resolved IP should be inside your consumer VPC CIDR. If you see public IPs such as `3.x.x.x` or `44.x.x.x`, private DNS is not in effect.

The `curl` request should return HTTP `200` with a body that starts with `Welcome to Cursor.` That response means the request reached a live Grok Build `api2` backend.

## Troubleshooting

| Symptom | Likely cause | Fix |
| :--- | :--- | :--- |
| Grok Build cannot complete the private connection to your Git provider | Grok Build cannot reach or attach to the endpoint service | Confirm the endpoint service name, region, and allowed principal match the values Grok Build provided, then contact Grok Build with the timestamp |
| Grok Build reports that the endpoint connection is waiting for customer action | The endpoint service requires approval in your AWS account | Review pending endpoint connection requests for the service and approve the Grok Build request |
| Bugbot or Cloud Agents connect to GHES but fail during app setup, repo sync, or webhook processing | A proxy in front of GHES is blocking or rewriting authenticated GitHub REST or GraphQL API requests | Allow Grok Build's GitHub App integration to use authenticated GitHub REST and GraphQL APIs |
| `api2.cursor.sh` resolves to public IPs | Private DNS is not in the resolver path used by GitHub Enterprise Server or GitLab Enterprise | Enable AWS-managed private DNS, or forward DNS to the endpoint VPC resolver |
| TCP to `api2.cursor.sh:443` times out | Security group, NACL, route table, or firewall blocks traffic to endpoint ENIs | Allow TCP 443 from your Git provider network to the endpoint ENIs |
| TLS fails for `api2.cursor.sh` | DNS points to the wrong target or the client is not using SNI | Check endpoint DNS and retry with SNI enabled |
| `curl https://api2.cursor.sh/` does not return `Welcome to Cursor.` | Traffic is not reaching a healthy Grok Build backend | Send Grok Build the timestamp, source VPC, and resolved endpoint IPs |
| Cloudflare Tunnel does not connect | `cloudflared` cannot reach Cloudflare or the token/config is wrong | Check outbound firewall rules, token, and `cloudflared` logs |

## Google private service connect

Grok Build doesn't offer customer-facing Google Private Service Connect.

If you need private connectivity from a GCP VPC to Grok Build services, or from Grok Build to a private service in your GCP project, contact Grok Build to scope the requirement. Use AWS PrivateLink or Cloudflare Tunnel when those deployment models fit.

## What to send Grok Build

For AWS PrivateLink to your Git provider or package registry:

* Endpoint service name
* AWS region
* Git or registry hostname
* Whether private DNS is enabled
* Whether your load balancer preserves client IPs or filters source IPs

For `api2.cursor.sh` over AWS PrivateLink:

* AWS principal Grok Build should allowlist
* VPC and region where you will create the interface endpoint
* Whether you plan to use AWS-managed private DNS or customer-managed DNS

For Cloudflare Tunnel:

* Internal origin URL
* Customer contacts for the secure 1Password share
* Any hostname or naming restrictions

## Further reading

* [AWS: Create an endpoint service](https://docs.aws.amazon.com/vpc/latest/privatelink/create-endpoint-service.html)
* [AWS: Manage DNS names for VPC endpoint services](https://docs.aws.amazon.com/vpc/latest/privatelink/manage-dns-names.html)
* [AWS: Access an AWS service using an interface VPC endpoint](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html)
* [Cloudflare Tunnel documentation](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/)
