{"record":{"id":"2523ece4b13ac589","repo":"amir20/dozzle","slug":"error-connecting-to-agent-w","errorCode":null,"errorMessage":"error connecting to agent: %w","messagePattern":"error connecting to agent: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/agent_test_command.go","lineNumber":26,"sourceCode":"\t\"github.com/amir20/dozzle/internal/agent\"\n\t\"github.com/rs/zerolog/log\"\n)\n\ntype AgentTestCmd struct {\n\tAddress string `arg:\"positional\"`\n}\n\nfunc (at *AgentTestCmd) Run(args Args, embeddedCerts embed.FS) error {\n\tcerts, err := ReadCertificates(embeddedCerts, args.CertPath, args.KeyPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading certificates: %w\", err)\n\t}\n\n\tlog.Info().Str(\"endpoint\", args.AgentTest.Address).Msg(\"Connecting to agent\")\n\n\tagent, err := agent.NewClient(args.AgentTest.Address, certs)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error connecting to agent: %w\", err)\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), args.Timeout)\n\tdefer cancel()\n\thost, err := agent.Host(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error fetching host info for agent: %w\", err)\n\t}\n\n\tlog.Info().Str(\"endpoint\", args.AgentTest.Address).Str(\"version\", host.AgentVersion).Str(\"name\", host.Name).Str(\"id\", host.ID).Msg(\"Successfully connected to agent\")\n\n\treturn nil\n}\n","sourceCodeStart":8,"sourceCodeEnd":39,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/agent_test_command.go#L8-L39","documentation":"Returned by AgentTestCmd.Run when agent.NewClient fails to build or dial the gRPC connection to the agent endpoint. This wraps dial-time errors: bad address syntax, DNS failure, or TLS handshake rejection (cert mismatch between tester and agent).","triggerScenarios":"Wrong/typo'd positional address (host:port); agent not running on the target port; TLS certs on the test machine differ from the agent's shared certs, causing handshake failure.","commonSituations":"Testing against an agent whose certs were regenerated separately; firewall dropping the port; address given without port so gRPC dial fails; hostname unresolvable from the test machine.","solutions":["Confirm the agent is listening: `nc -zv <host> 7007` from the test machine.","Use the exact shared cert pair: --cert-path/--key-path matching the agent's certs.","Check the address format is host:port, e.g. 10.0.0.5:7007.","Open the firewall for the agent port on the target host.","Regenerate one shared cert pair and deploy it to both sides."],"exampleFix":"// before\n./dozzle agent-test 10.0.0.5  # missing port, wrong certs\n// after\n./dozzle agent-test --cert-path shared-cert.pem --key-path shared-key.pem 10.0.0.5:7007","handlingStrategy":"try-catch","validationCode":"nc -zv \"${ADDR%%:*}\" \"${ADDR##*:}\" || { echo \"agent unreachable at $ADDR\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if err := agentTestCmd.Run(args, embeddedCerts); err != nil {\n  if strings.Contains(err.Error(), \"error connecting to agent\") {\n    log.Fatal().Err(err).Msg(\"verify host:port, agent running, and matching TLS certs\")\n  }\n}","preventionTips":["Always specify host:port for the agent address","Share a single cert pair between agent and tester","Test network reachability before gRPC dialing","Keep agent ports open in firewalls/security groups"],"tags":["grpc","tls","connectivity"],"backgroundTag":"connection-refused","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}