{"record":{"id":"c2a9b0b19e1bacb0","repo":"grafana/k6","slug":"failed-to-dial-w","errorCode":null,"errorMessage":"failed to dial: %w","messagePattern":"failed to dial: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/insights/client.go","lineNumber":153,"sourceCode":"func (c *Client) Dial(ctx context.Context) error {\n\tc.connMu.Lock()\n\tdefer c.connMu.Unlock()\n\n\tif c.conn != nil {\n\t\treturn ErrClientAlreadyInitialized\n\t}\n\n\topts, err := dialOptionsFromClientConfig(c.cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create dial options: %w\", err)\n\t}\n\n\tctx, cancel := context.WithTimeout(ctx, c.cfg.ConnectConfig.Timeout)\n\tdefer cancel()\n\n\tconn, err := grpc.DialContext(ctx, c.cfg.IngesterHost, opts...) //nolint:staticcheck\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to dial: %w\", err)\n\t}\n\n\tc.client = ingester.NewIngesterServiceClient(conn)\n\tc.conn = conn\n\n\treturn nil\n}\n\n// IngestRequestMetadatasBatch ingests a batch of request metadatas.\nfunc (c *Client) IngestRequestMetadatasBatch(ctx context.Context, requestMetadatas RequestMetadatas) error {\n\tc.connMu.RLock()\n\tclosed := c.conn == nil\n\tc.connMu.RUnlock()\n\tif closed {\n\t\treturn ErrClientClosed\n\t}\n\n\tif len(requestMetadatas) < 1 {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/insights/client.go#L135-L171","documentation":"Client.Dial (internal/cloudapi/insights/client.go:148-155) calls grpc.DialContext against cfg.IngesterHost within ConnectConfig.Timeout; when the connection cannot be established in that window (the config can set WithBlock and FailOnNonTempDialError, client.go:210-216, making failures eager and non-retryable at dial time) the error is wrapped as 'failed to dial'. It means the insights ingester endpoint was unreachable or refused the connection/TLS handshake.","triggerScenarios":"DNS resolution failure or blocked egress to the insights ingester host:port; TLS handshake rejected (server requires client CA or TLS1.3 is stripped by a middlebox); ConnectConfig.Timeout too short for a high-latency path; wrong IngesterHost from the cloud runtime config.","commonSituations":"CI runners or Kubernetes clusters with egress allowlists that miss the insights ingestion domain; corporate TLS-intercepting proxies incompatible with gRPC; slow first-hop satellite links hitting the connect timeout.","solutions":["Verify reachability from the same environment: 'nc -vz <ingester-host> <port>' and 'openssl s_client -connect host:port'","Allow egress to the insights ingest endpoint in firewall/proxy policy (or route through the supported private-link setup)","If a custom CA is required, set TLSConfig.CertFile correctly (see error 'failed to load TLS credentials from file')","Increase the connect timeout if the network path legitimately needs longer, and re-run"],"exampleFix":"# before - egress blocked, dial times out\nk6 cloud run --local-execution script.js   # failed to dial: context deadline exceeded\n\n# after - allow the ingester host, then re-run\n# (network policy): allow egress tcp/443 to insights.ingest.grafana.net\nk6 cloud run --local-execution script.js","handlingStrategy":"retry","validationCode":"# pre-flight from the same environment before the run\ngetent hosts insights.<your-ingest-host> >/dev/null || echo 'DNS for insights ingester missing'\nnc -z -w 5 <ingester-host> 443 || echo 'egress to insights ingester blocked'","typeGuard":null,"tryCatchPattern":"if err := client.Dial(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to dial\") {\n        // network/TLS reachability issue: safe to retry after fixing egress; not a config-format error\n    }\n}","preventionTips":["Allowlist the insights ingestion host:443 in CI/Kubernetes egress policy alongside the API host","Keep runner clocks NTP-synced and CA bundles current so TLS handshakes succeed","Size ConnectConfig.Timeout for your real network latency before high-latitude deployments"],"tags":["cloud","grpc","network","insights","timeout","tls"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}