{"record":{"id":"ca1f3955bfcccfe2","repo":"hashicorp/nomad","slug":"failed-to-get-conn-v","errorCode":null,"errorMessage":"failed to get conn: %v","messagePattern":"failed to get conn: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pool/pool.go","lineNumber":472,"sourceCode":"\tif c, ok := p.pool[conn.addr.String()]; ok && c == conn {\n\t\tdelete(p.pool, conn.addr.String())\n\t}\n\tp.Unlock()\n\n\t// Close down immediately if idle\n\tif refCount := atomic.LoadInt32(&conn.refCount); refCount == 0 {\n\t\tconn.Close()\n\t}\n}\n\n// getClient is used to get a usable client for an address\nfunc (p *ConnPool) getRPCClient(region string, addr net.Addr) (*Conn, *StreamClient, error) {\n\tretries := 0\nSTART:\n\t// Try to get a conn first\n\tconn, err := p.acquire(region, addr)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to get conn: %v\", err)\n\t}\n\n\t// Get a client\n\tclient, err := conn.getRPCClient()\n\tif err != nil {\n\t\tp.clearConn(conn)\n\t\tconn.releaseUse()\n\n\t\t// Try to redial, possible that the TCP session closed due to timeout\n\t\tif retries == 0 {\n\t\t\tretries++\n\t\t\tgoto START\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"failed to start stream: %v\", err)\n\t}\n\treturn conn, client, nil\n}\n","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pool/pool.go#L454-L490","documentation":"getRPCClient first acquires a connection from the pool; any error from acquire (shutdown, lead thread failure, dial errors) is wrapped as 'failed to get conn: <err>'. This is the outer wrapper for all pool-acquisition failures on the normal RPC path.","triggerScenarios":"pool.RPC -> getRPCClient where p.acquire fails: pool shut down, TCP dial timeout/refused, or lead-thread race error.","commonSituations":"Server down or restarting, wrong advertise address in config, network partition, TLS/mTLS mismatch preventing dial, agent shutdown in flight.","solutions":["Check the inner error: dial refused/timeout means fix connectivity or the server address","Verify the Nomad server is running and its advertise RPC address is correct","Check TLS/CA configuration if connections are rejected","Retry the RPC; the pool transparently redials on transient failures"],"exampleFix":"// before: hardcoding a stale server address\naddr := \"/ip/10.0.0.1/port/4647\" // server moved\n// after: resolve from client config\naddr := nodeAddrFromServers(srv)\n","handlingStrategy":"retry","validationCode":"// precheck connectivity before RPC\nc, err := net.DialTimeout(\"tcp\", addr.String(), 2*time.Second)\nif err != nil { return fmt.Errorf(\"server unreachable: %w\", err) }\nc.Close()","typeGuard":null,"tryCatchPattern":"err := pool.RPC(region, addr, method, args, out)\nif err != nil {\n    var ne net.Error\n    if errors.As(err, &ne) || strings.Contains(err.Error(), \"failed to get conn\") {\n        // backoff + retry; also try another server from the server list\n    }\n    return err\n}","preventionTips":["Verify advertise addresses and firewall rules for the RPC port","Check TLS/mTLS config on both client and server","Keep the server list fresh so callers can fail over"],"tags":["rpc","network","connection-refused"],"backgroundTag":"connection-refused","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}