curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them
Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →
A numbered curl error almost always means the request never reached the application or the response never came back: a DNS, network, proxy or certificate problem. An API error looks different — an HTTP 4xx or 5xx in the response. Below is a code table, common causes and commands that quickly show where it breaks.
curl error or API error
If curl prints curl: (number) and a message, the connection failed or broke. If a response with 401, 404 or 500 arrived, the network works and the application returned the error. The -f flag turns HTTP errors into exit code 22, so in scripts remember that 22 already means a server response.
curl: (22) The requested URL returned error: 404, 500, 618
Code 22 only happens with -f (--fail): the server answered, and curl turned its HTTP status of 400 or higher into an error. The number after the colon is the server status code. Standard codes range from 100 to 599, but gateways and applications sometimes send their own, such as 618 or 999: then only that service knows what the number means, so check its docs or log. To see what the server wrote in the response body, replace -f with --fail-with-body (curl 7.76 or newer) or run the request with -v.

How to find where it breaks
Run the same request with -v: you see which IP the name resolved to, whether the connection succeeded, how the TLS handshake went and what the server answered. An error before the Connected line is network or DNS, between it and the response is TLS or proxy, after the response is the application.
Do not disable certificate checks for good
The -k flag removes error 60 but also the protection against a spoofed server. Fine for one-off diagnostics, not for scripts and autotests: point to the right root certificate with --cacert or install it in the system.

curl error codes
| Code | Message | Usually means |
|---|---|---|
| 6 | Could not resolve host | The host name did not resolve: typo, no DNS, VPN needed |
| 7 | Failed to connect | The server refuses the connection: wrong port, service down, firewall |
| 22 | The requested URL returned error | With -f the server returned HTTP 400 or higher |
| 28 | Operation timed out | No connection or response in time: network, proxy, slow server |
| 35 | SSL connect error | TLS handshake failed: TLS version, intercepting proxy, old curl |
| 52 | Empty reply from server | The server closed without answering: crashed process, HTTP on an HTTPS port |
| 56 | Failure when receiving data | The connection broke during the response |
| 60 | SSL certificate problem | Certificate failed verification: self-signed, missing intermediate |
Diagnostic commands
# подробный вывод: DNS, подключение, TLS, заголовки
curl -v https://api.example.com/health
# только код ответа и время по этапам
curl -s -o /dev/null -w "code=%{http_code} dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} total=%{time_total}\n" https://api.example.com/health
# таймауты: 5 секунд на подключение, 30 на весь запрос
curl --connect-timeout 5 --max-time 30 https://api.example.com/orders
# свой корневой сертификат вместо -k
curl --cacert ./corp-root.pem https://api.internal.example/healthA long time to connect points to network or proxy. A long total alone means the server responds slowly, which is an application question.
Common situations
- Works in the browser, error 60 in curl. The browser knows the corporate root certificate and curl does not: pass it with --cacert.
- Error 7 on localhost. The service listens on another port or only IPv6; try 127.0.0.1 instead of localhost.
- Error 28 via VPN or proxy. Set the proxy with -x or check https_proxy and no_proxy.
- Error 52. Usually the server process crashed on the request: read its log.
When the connection works and an HTTP error code arrives, see error 401 and error 500.
More on curl
Section overview and all guides: curl command cheat sheet: flags and examples for APIs.
- curl on Windows and PowerShell: how to run it and why commands fail
- Download a file with curl: -o, -O, redirects and resume
- curl through a proxy: -x, environment variables, SOCKS and no_proxy
- PHP cURL: GET and POST requests with JSON, headers and error handling
- Webhook: what it is, how it works and how to test it
Frequently asked questions
What does curl error 28 mean?
Operation timed out: no connection or response in time. Set limits with --connect-timeout and --max-time.
What does curl error 35 mean?
SSL connect error: the TLS handshake failed, often due to an intercepting proxy, TLS version or an old curl.
How do I fix SSL certificate problem?
Pass the right root certificate with --cacert or install it; -k is for one-off diagnostics only.
curl error vs API error?
A numbered curl error means no connection; an API error is an HTTP 4xx or 5xx response.
Repeat this on your own API
Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.
Download FreeDownload and first runNo sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.
References
Start with the linked example and compare its result with your own test requirement.