{"record":{"id":"3fc5ca0bdd180651","repo":"hashicorp/terraform","slug":"error-connecting-to-proxy-s","errorCode":null,"errorMessage":"Error connecting to proxy: %s","messagePattern":"Error connecting to proxy: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/communicator/ssh/communicator.go","lineNumber":846,"sourceCode":"\taddr string,\n\tp *proxyInfo) func() (net.Conn, error) {\n\treturn func() (net.Conn, error) {\n\t\tlog.Printf(\"[DEBUG] Connecting to bastion: %s\", bAddr)\n\t\tvar bastion *ssh.Client\n\t\tvar err error\n\n\t\t// Wrap connection to bastion server if proxy server is configured\n\t\tif p != nil {\n\t\t\tvar pConn net.Conn\n\t\t\tvar bConn ssh.Conn\n\t\t\tvar bChans <-chan ssh.NewChannel\n\t\t\tvar bReq <-chan *ssh.Request\n\n\t\t\tRegisterDialerType()\n\t\t\tpConn, err = newHttpProxyConn(p, bAddr)\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Error connecting to proxy: %s\", err)\n\t\t\t}\n\n\t\t\tbConn, bChans, bReq, err = ssh.NewClientConn(pConn, bAddr, bConf)\n\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Error creating new client connection via proxy: %s\", err)\n\t\t\t}\n\n\t\t\tbastion = ssh.NewClient(bConn, bChans, bReq)\n\t\t} else {\n\t\t\tbastion, err = ssh.Dial(bProto, bAddr, bConf)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Error connecting to bastion: %s\", err)\n\t\t}\n\n\t\tlog.Printf(\"[DEBUG] Connecting via bastion (%s) to host: %s\", bAddr, addr)","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/communicator/ssh/communicator.go#L828-L864","documentation":"Raised in BastionConnectFunc when newHttpProxyConn(p, bAddr) fails, meaning the initial TCP/HTTP-CONNECT tunnel through the configured HTTP proxy to the bastion host could not be established. This is the proxy-layer connection failure before any SSH handshake occurs.","triggerScenarios":"When both a bastion_host and proxy_host are configured, the communicator first dials the HTTP proxy and issues a CONNECT to the bastion address. This error fires if the proxy is unreachable, refuses the connection, or the CONNECT tunnel fails.","commonSituations":"Wrong proxy_host or proxy_port, the proxy server is down, a firewall blocks the proxy, proxy authentication is misconfigured (wrong proxy_user_name/proxy_user_password), or the proxy cannot reach the bastion host.","solutions":["Verify proxy_host and proxy_port are correct and the proxy is reachable (curl -x http://proxy:port bastion:22).","Check proxy_user_name and proxy_user_password are correct if the proxy requires auth.","Confirm the proxy server can route to the bastion host address.","Ensure no firewall or security group blocks the terraform runner to the proxy."],"exampleFix":"// before\nconnection {\n  bastion_host = var.bastion\n  proxy_host   = var.proxy\n  proxy_port   = 8080\n}\n\n// after\nconnection {\n  bastion_host     = var.bastion\n  proxy_host       = var.proxy\n  proxy_port       = 3128\n  proxy_user_name  = var.proxy_user\n  proxy_user_password = var.proxy_pass\n}","handlingStrategy":"validation","validationCode":"// Validate proxy reachability before provisioning\nfunc validateProxyReachability(proxyHost string, proxyPort uint16) error {\n    conn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"%s:%d\", proxyHost, proxyPort), 5*time.Second)\n    if err != nil {\n        return fmt.Errorf(\"proxy %s:%d is not reachable: %w\", proxyHost, proxyPort, err)\n    }\n    conn.Close()\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test proxy connectivity with curl -x before running terraform.","Verify proxy credentials (proxy_user_name/proxy_user_password) are correct.","Ensure the proxy can route CONNECT requests to the bastion host and port."],"tags":["ssh","proxy","http-proxy","bastion","network","terraform"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}