Troubleshooting
Common cURL errors and how to fix them
Most curl errors come from quoting, missing headers, invalid JSON, authentication problems, redirects, SSL settings, or differences between shells.
Invalid JSON or missing Content-Type
If an API rejects your JSON body, confirm that the JSON is valid and that you sent Content-Type: application/json. Many server frameworks rely on that header to parse the body.
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Ada"}'Authentication failures
A 401 response usually means missing or invalid credentials. A 403 response often means the credentials are valid but do not have permission.
Check whether the API expects a bearer token, basic auth, API key header, cookie, or signed request.
Shell quoting problems
A curl command that works in bash may fail in PowerShell because the shells parse quotes differently. If a command came from documentation, make sure it matches your terminal.
When in doubt, simplify the command and add flags back one at a time.
Redirects, SSL, and timeouts
If a request returns a redirect instead of the final response, try -L to follow redirects. For local development with self-signed certificates, -k can bypass certificate verification, but avoid it in production.
For slow APIs, add a timeout so scripts do not hang forever.
curl -L --max-time 10 https://example.com/old-urlTry it with curlcode
Have a curl command already? Paste it into one of the converters below to generate language-specific HTTP request code.
Frequently asked questions
Why does curl return 401?
The request is missing valid authentication credentials or the token has expired.
Why does my curl JSON fail?
Check the Content-Type header, JSON syntax, and shell quoting.
What does curl -k do?
It allows insecure TLS connections by skipping certificate verification. Use it only for local development or debugging.
How do I debug a curl command?
Use verbose output, simplify the command, check headers and body, then compare the result with API documentation.
Related guides
What does cURL mean?
Learn what cURL means, why developers use it, and how a simple curl command turns a URL into a repeatable API request.
What is a cURL command?
A practical explanation of curl commands, their structure, common flags, and how developers use them to test APIs.
How to copy as cURL from Chrome DevTools
Use Chrome DevTools to copy a real browser request as cURL, inspect headers and cookies, and convert it into reusable code.