Back to blog

    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.

    8 min readUpdated 2026-04-28

    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.

    Correct JSON request
    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.

    Redirects and timeout
    curl -L --max-time 10 https://example.com/old-url

    Try 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