{"record":{"id":"4070752f41406bdf","repo":"ginuerzh/gost","slug":"bind-on-s-failure","errorCode":null,"errorMessage":"Bind on %s failure","messagePattern":"Bind on (.+?) failure","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"forward.go","lineNumber":528,"sourceCode":"\n\tconn, err = socks5Handshake(conn, userSocks5HandshakeOption(l.chain.LastNode().User))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq := gosocks5.NewRequest(CmdMuxBind, toSocksAddr(l.addr))\n\tif err := req.Write(conn); err != nil {\n\t\tlog.Log(\"[rtcp] SOCKS5 BIND request: \", err)\n\t\treturn nil, err\n\t}\n\n\trep, err := gosocks5.ReadReply(conn)\n\tif err != nil {\n\t\tlog.Log(\"[rtcp] SOCKS5 BIND reply: \", err)\n\t\treturn nil, err\n\t}\n\tif rep.Rep != gosocks5.Succeeded {\n\t\tlog.Logf(\"[rtcp] bind on %s failure\", l.addr)\n\t\treturn nil, fmt.Errorf(\"Bind on %s failure\", l.addr.String())\n\t}\n\tlog.Logf(\"[rtcp] BIND ON %s OK\", rep.Addr)\n\n\t// Upgrade connection to multiplex stream.\n\tsession, err := smux.Server(conn, smux.DefaultConfig())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tl.session = &muxSession{\n\t\tconn:    conn,\n\t\tsession: session,\n\t}\n\n\treturn l.session, nil\n}\n\nfunc (l *tcpRemoteForwardListener) waitConnectSOCKS5(conn net.Conn) (net.Conn, error) {\n\tconn, err := socks5Handshake(conn, userSocks5HandshakeOption(l.chain.LastNode().User))","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/forward.go#L510-L546","documentation":"This error comes from the rtcp (relay/tunnel over SOCKS5 BIND) forwarding path. The client sent a SOCKS5 BIND request to the relay and the server replied with a non-Success REP code, meaning the remote side refused or failed to establish the BIND. The connection is aborted and no smux session is created.","triggerScenarios":"getSession calls the SOCKS5 connector with BIND; the gosocks5 reply (rep.Rep) is anything other than gosocks5.Succeeded — e.g. connection refused/blocked at the relay, port allocation failure, or auth/permission denial on the relay node.","commonSituations":"Remote port forwarding through a gost relay when the relay host cannot open the requested port; firewall on the relay blocking the listen; relay configured with permissions that exclude BIND; relay behind NAT unable to accept inbound connections.","solutions":["Check relay server logs for the SOCKS5 BIND failure reason and fix the underlying cause (port in use, firewall, permission rules).","Verify the relay node allows the bind action in its permissions config (e.g. permissions like connect,bind).","Confirm the relay host is publicly reachable and the target bind port is not occupied.","Retry after correcting the tunnel/relay configuration; the error is not transient-safe to blind-retry."],"exampleFix":"// before: bind relay without bind permission\npermissions: \"connect\"\n// after\npermissions: \"connect,bind\"","handlingStrategy":"retry","validationCode":"// probe relay before opening tunnel\nfunc relayReachable(addr string) bool {\n    c, err := net.DialTimeout(\"tcp\", addr, 5*time.Second)\n    if err != nil { return false }\n    c.Close(); return true\n}","typeGuard":null,"tryCatchPattern":"for i := 0; i < 3; i++ {\n    s, err := getSession(conn)\n    if err == nil { return s }\n    if !strings.Contains(err.Error(), \"Bind on\") { return nil, err }\n    time.Sleep(time.Duration(1<<i) * time.Second)\n}\nreturn nil, errors.New(\"bind kept failing\")","preventionTips":["Only retry after confirming the relay is up","Escalate to config fix after repeated bind failures","Monitor relay port availability"],"tags":["network","socks5","tunnel","bind"],"backgroundTag":"socks5-bind-failure","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}