{"record":{"id":"c82668fecb7bece5","repo":"dgraph-io/dgraph","slug":"failed-to-connect-to-endpoint-s-w","errorCode":null,"errorMessage":"failed to connect to endpoint [%s]: %w","messagePattern":"failed to connect to endpoint \\[(.+?)\\]: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/dgraphimport/import_client.go","lineNumber":36,"sourceCode":"\n\t\"github.com/dgraph-io/badger/v4\"\n\t\"github.com/dgraph-io/dgo/v250\"\n\t\"github.com/dgraph-io/dgo/v250/protos/api\"\n\t\"github.com/dgraph-io/ristretto/v2/z\"\n\n\t\"github.com/golang/glog\"\n\t\"golang.org/x/sync/errgroup\"\n)\n\n// newClient creates a new import client with the specified endpoint and gRPC options.\nfunc newClient(connectionString string) (api.DgraphClient, error) {\n\tif connectionString == \"\" {\n\t\treturn nil, fmt.Errorf(\"connection string cannot be empty\")\n\t}\n\n\tdg, err := dgo.Open(connectionString)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to connect to endpoint [%s]: %w\", connectionString, err)\n\t}\n\n\tglog.Infof(\"[import] Successfully connected to Dgraph endpoint: %s\", connectionString)\n\treturn dg.GetAPIClients()[0], nil\n}\n\nfunc Import(ctx context.Context, connectionString string, bulkOutDir string) error {\n\tif bulkOutDir == \"\" {\n\t\treturn fmt.Errorf(\"bulk output directory cannot be empty\")\n\t}\n\n\tdg, err := newClient(connectionString)\n\tif err != nil {\n\t\treturn err\n\t}\n\tresp, err := initiateSnapshotStream(ctx, dg)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/dgraphimport/import_client.go#L18-L54","documentation":"dgo.Open failed to establish a gRPC connection to the supplied endpoint; newClient wraps the original error with the endpoint for context. This is a connectivity/handshake failure, not a validation error — the string was non-empty but unusable.","triggerScenarios":"Alpha down or unreachable, wrong host/port (gRPC 9080 vs HTTP 8080), DNS failure, TLS mismatch (plain connection to a TLS-enabled cluster or vice-versa), malformed connection string options.","commonSituations":"Cluster not yet started, k8s service name/port wrong, security mode (TLS) enabled client-side not configured, firewall/network policy blocking 9080, typo in host.","solutions":["Verify the Alpha gRPC port: curl the HTTP health port and confirm the process is up (kubectl get pods / docker ps).","Test reachability: grpcurl or nc -zv <host> 9080.","If the cluster uses TLS/ACL, supply the matching connection-string options (certs, tls) to dgo.Open.","Read the wrapped cause (%w) with errors.Unwrap / %v to distinguish DNS vs connection refused vs TLS errors."],"exampleFix":"// before\ndg, err := dgraphimport.Import(ctx, \"localhost:8080\", outDir) // HTTP port, not gRPC\n// after\ndg, err := dgraphimport.Import(ctx, \"localhost:9080\", outDir)","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"alpha1:9080\", 3*time.Second)\nif err != nil {\n    return fmt.Errorf(\"alpha gRPC port unreachable before dial: %v\", err)\n}\nconn.Close()","typeGuard":null,"tryCatchPattern":"if err := dgraphimport.Import(ctx, addr, outDir); err != nil {\n    if strings.Contains(err.Error(), \"failed to connect to endpoint\") {\n        // transient? retry with backoff; else surface unwrapped cause\n        var cause error = errors.Unwrap(errors.Unwrap(err))\n        return fmt.Errorf(\"dial failed: %v\", cause)\n    }\n    return err\n}","preventionTips":["Use the gRPC port (9080), not the HTTP port (8080).","Pre-check TCP reachability before import jobs.","Match TLS/security settings between client connection string and cluster config.","Verify pod/service DNS names resolve inside the same network."],"tags":["grpc","network","connection","tls","import"],"backgroundTag":"grpc-connection-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}