{"record":{"id":"b837958e2455de00","repo":"valyala/fasthttp","slug":"fasthttp-no-free-connections-available-to-host","errorCode":null,"errorMessage":"fasthttp: no free connections available to host","messagePattern":"fasthttp: no free connections available to host","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client.go","lineNumber":1787,"sourceCode":"\t}\n\n\treturn c.transport().RoundTrip(c, req, resp)\n}\n\nfunc (c *HostClient) transport() RoundTripper {\n\tif c.Transport == nil {\n\t\treturn DefaultTransport\n\t}\n\treturn c.Transport\n}\n\nvar (\n\t// ErrNoFreeConns is returned when no free connections available\n\t// to the given host.\n\t//\n\t// Increase the allowed number of connections per host if you\n\t// see this error.\n\tErrNoFreeConns = errors.New(\"fasthttp: no free connections available to host\")\n\n\t// ErrConnectionClosed may be returned from client methods if the server\n\t// closes connection before returning the first response byte.\n\t//\n\t// If you see this error, then either fix the server by returning\n\t// 'Connection: close' response header before closing the connection\n\t// or add 'Connection: close' request header before sending requests\n\t// to broken server.\n\tErrConnectionClosed = errors.New(\"fasthttp: the server closed connection before returning the first response byte. \" +\n\t\t\"make sure the server returns 'connection: close' response header before closing the connection\")\n\n\t// ErrConnPoolStrategyNotImpl is returned when HostClient.ConnPoolStrategy is not implement yet.\n\t// If you see this error, then you need to check your HostClient configuration.\n\tErrConnPoolStrategyNotImpl = errors.New(\"fasthttp: connection pool strategy is not implement\")\n)\n\ntype timeoutError struct{}\n","sourceCodeStart":1769,"sourceCodeEnd":1805,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/client.go#L1769-L1805","documentation":"ErrNoFreeConns is returned when the per-host connection pool has no idle connections available and the configured maximum number of connections per host is already open. fasthttp refuses to create more connections to protect the host.","triggerScenarios":"High-concurrency Client/HostClient.Do calls to the same host when MaxConnsPerHost is saturated and all connections are busy; slow server responses keeping connections checked out.","commonSituations":"Load tests or burst traffic where MaxConnsPerHost is too low; slow downstream API causing connection pile-up; leaked long-lived responses pinning pooled connections.","solutions":["Increase Client.MaxConnsPerHost to accommodate your concurrency","Fix why connections are busy: slow endpoints, long timeouts, or leaked response bodies","Add client-side throttling/queueing instead of overwhelming the pool","Retry with backoff on this error (e.g. via Client.RetryIf)"],"exampleFix":"// before\nc := &fasthttp.Client{} // default per-host conns\n// after\nc := &fasthttp.Client{\n    MaxConnsPerHost: 1024,\n    MaxIdleConnDuration: 30 * time.Second,\n    RetryIf: func(req *fasthttp.Request, resp *fasthttp.Response, err error) bool {\n        return errors.Is(err, fasthttp.ErrNoFreeConns)\n    },\n}","handlingStrategy":"retry","validationCode":"if concurrencyLimit > client.MaxConnsPerHost {\n    client.MaxConnsPerHost = concurrencyLimit\n}","typeGuard":null,"tryCatchPattern":"if errors.Is(err, fasthttp.ErrNoFreeConns) {\n    time.Sleep(backoff)\n    return do(req, resp) // bounded retry with jitter\n}","preventionTips":["Size MaxConnsPerHost to your peak concurrency","Watch for slow endpoints pinning connections; tighten timeouts","Enable RetryIf to auto-retry ErrNoFreeConns","Throttle client-side instead of exceeding pool capacity"],"tags":["network","connection-pool","client","concurrency"],"backgroundTag":"no-free-connections","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}