{"record":{"id":"608daee111a08cd0","repo":"fatedier/frp","slug":"create-vhost-http-listener-error-v","errorCode":null,"errorMessage":"create vhost http listener error, %v","messagePattern":"create vhost http listener error, (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/service.go","lineNumber":319,"sourceCode":"\t\tsvr.rc.HTTPReverseProxy = rp\n\n\t\taddress := net.JoinHostPort(cfg.ProxyBindAddr, strconv.Itoa(cfg.VhostHTTPPort))\n\t\tprotocols := new(http.Protocols)\n\t\tprotocols.SetHTTP1(true)\n\t\tprotocols.SetUnencryptedHTTP2(true)\n\t\tserver := &http.Server{\n\t\t\tAddr:              address,\n\t\t\tHandler:           rp,\n\t\t\tReadHeaderTimeout: 60 * time.Second,\n\t\t\tProtocols:         protocols,\n\t\t}\n\t\tvar l net.Listener\n\t\tif httpMuxOn {\n\t\t\tl = svr.muxer.ListenHTTP(1)\n\t\t} else {\n\t\t\tl, err = net.Listen(\"tcp\", address)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"create vhost http listener error, %v\", err)\n\t\t\t}\n\t\t}\n\t\tgo func() {\n\t\t\t_ = server.Serve(l)\n\t\t}()\n\t\tlog.Infof(\"http service listen on %s\", address)\n\t}\n\n\t// Create https vhost muxer.\n\tif cfg.VhostHTTPSPort > 0 {\n\t\tvar l net.Listener\n\t\tif httpsMuxOn {\n\t\t\tl = svr.muxer.ListenHTTPS(1)\n\t\t} else {\n\t\t\taddress := net.JoinHostPort(cfg.ProxyBindAddr, strconv.Itoa(cfg.VhostHTTPSPort))\n\t\t\tl, err = net.Listen(\"tcp\", address)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"create server listener error, %v\", err)","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/server/service.go#L301-L337","documentation":"When vhostHTTPPort > 0 and HTTP is not multiplexed onto the main listener (httpMuxOn false), frps binds a dedicated TCP listener on ProxyBindAddr:VhostHTTPPort for HTTP vhost routing. A bind failure here is fatal to service creation.","triggerScenarios":"vhostHTTPPort colliding with another web server on the host (nginx, apache, another frps); ProxyBindAddr invalid; privileged port without capability.","commonSituations":"Running frps on a box that already serves HTTP on 80; two frps instances sharing a host; setting vhostHTTPPort = 8080 where 8080 is taken.","solutions":["Stop the conflicting service or move vhostHTTPPort to a free port","Update every http-type proxy/custom domain DNS or reverse proxy that targets the old port","Alternatively set bindPort = vhostHTTPPort to multiplex HTTP onto the main listener (httpMuxOn) and avoid the extra bind"],"exampleFix":"# before\nbindPort = 7000\nvhostHTTPPort = 8080   # nginx already on 8080\n\n# after\nbindPort = 7000\nvhostHTTPPort = 8090","handlingStrategy":"validation","validationCode":"if cfg.VhostHTTPPort > 0 && cfg.BindPort != cfg.VhostHTTPPort {\n    if l, err := net.Listen(\"tcp\", net.JoinHostPort(cfg.ProxyBindAddr, strconv.Itoa(cfg.VhostHTTPPort))); err != nil {\n        return fmt.Errorf(\"vhost http port %d unavailable: %w\", cfg.VhostHTTPPort, err)\n    } else { l.Close() }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not colocate frps vhostHTTPPort with an existing web server on the same port","Consider multiplexing (bindPort == vhostHTTPPort) to reduce the number of binds","Automate port-collision checks in the frps deployment script"],"tags":["frps","startup","vhost","http","port"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}