{"id":"ba5dbcec6efac9a0","repo":"labstack/echo","slug":"errinvalidlistenernetwork","errorCode":"ErrInvalidListenerNetwork","errorMessage":"invalid listener network","messagePattern":"invalid listener network","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"httperror.go","lineNumber":35,"sourceCode":"\tErrNotFound                    = &httpError{http.StatusNotFound}              // 404\n\tErrMethodNotAllowed            = &httpError{http.StatusMethodNotAllowed}      // 405\n\tErrRequestTimeout              = &httpError{http.StatusRequestTimeout}        // 408\n\tErrStatusRequestEntityTooLarge = &httpError{http.StatusRequestEntityTooLarge} // 413\n\tErrUnsupportedMediaType        = &httpError{http.StatusUnsupportedMediaType}  // 415\n\tErrTooManyRequests             = &httpError{http.StatusTooManyRequests}       // 429\n\tErrInternalServerError         = &httpError{http.StatusInternalServerError}   // 500\n\tErrBadGateway                  = &httpError{http.StatusBadGateway}            // 502\n\tErrServiceUnavailable          = &httpError{http.StatusServiceUnavailable}    // 503\n)\n\n// The following errors fall into 500 (InternalServerError) category\nvar (\n\tErrValidatorNotRegistered = errors.New(\"validator not registered\")\n\tErrRendererNotRegistered  = errors.New(\"renderer not registered\")\n\tErrInvalidRedirectCode    = errors.New(\"invalid redirect status code\")\n\tErrCookieNotFound         = errors.New(\"cookie not found\")\n\tErrInvalidCertOrKeyType   = errors.New(\"invalid cert or key type, must be string or []byte\")\n\tErrInvalidListenerNetwork = errors.New(\"invalid listener network\")\n)\n\n// HTTPStatusCoder is an interface that errors can implement to produce status code for HTTP response\ntype HTTPStatusCoder interface {\n\tStatusCode() int\n}\n\n// StatusCode returns status code from err if it implements HTTPStatusCoder interface.\n// If err does not implement the interface, it returns 0.\nfunc StatusCode(err error) int {\n\tvar sc HTTPStatusCoder\n\tif errors.As(err, &sc) {\n\t\treturn sc.StatusCode()\n\t}\n\treturn 0\n}\n\n// ResolveResponseStatus returns the Response and HTTP status code that should be (or has been) sent for rw,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/labstack/echo/blob/05489dc1730161df26b72d1ae2a3ba6fb8178fc7/httperror.go#L17-L53","documentation":"ErrInvalidListenerNetwork is a sentinel for an invalid network type passed to the listener configuration. StartConfig.ListenerNetwork defaults to \"tcp\" and is forwarded to net.ListenConfig.Listen; valid values include tcp, tcp4, tcp6, unix, etc. An unrecognized network string causes the listener to fail to start.","triggerScenarios":"Setting StartConfig.ListenerNetwork (or the equivalent Echo listener config) to an unrecognized value like \"http\", \"ip\", or a typo such as \"tcp\". The net.Listen call fails and the server does not start.","commonSituations":"Typo in the network string. Confusing the network type with the scheme (http/https). Trying to use a network not supported on the target OS.","solutions":["Use \"tcp\" for standard TCP (IPv4+IPv6), \"tcp4\" / \"tcp6\" for specific IP versions, or \"unix\" for Unix domain sockets","Omit ListenerNetwork to accept the default \"tcp\"","If you need a custom listener, provide your own net.Listener via StartConfig.Listener instead"],"exampleFix":"// before\ncfg := echo.StartConfig{\n    ListenerNetwork: \"http\",\n    Address:         \":8080\",\n}\n\n// after\ncfg := echo.StartConfig{\n    ListenerNetwork: \"tcp\",\n    Address:         \":8080\",\n}","handlingStrategy":"validation","validationCode":"var validNetworks = map[string]bool{\"tcp\": true, \"tcp4\": true, \"tcp6\": true, \"unix\": true, \"unixpacket\": true}\nfunc validListenerNetwork(n string) bool { return validNetworks[n] }\nif !validListenerNetwork(cfg.ListenerNetwork) {\n    return fmt.Errorf(\"invalid listener network: %s\", cfg.ListenerNetwork)\n}","typeGuard":null,"tryCatchPattern":"if err := echo.StartServer(cfg); err != nil {\n    if errors.Is(err, echo.ErrInvalidListenerNetwork) {\n        log.Fatal(\"listener network must be tcp/tcp4/tcp6/unix\")\n    }\n    return err\n}","preventionTips":["Use \"tcp\" (default) for standard TCP listeners","Validate the network string against a whitelist at startup","Provide a pre-built net.Listener via StartConfig.Listener for advanced cases"],"tags":["listener","network","server-startup","configuration"],"analyzedSha":"05489dc1730161df26b72d1ae2a3ba6fb8178fc7","analyzedAt":"2026-08-04T21:32:47.783Z","schemaVersion":2}