Use curl -I when you need response headers fast. It is the tiny flashlight of API debugging. It tells you status, redirects, cache rules, cookies, content type, and server hints without downloading the body.
TLDR: A curl HEAD request is best for quick checks like curl -I https://api.example.com/users. It sends a HEAD request and shows headers only. In one support case, a team checked 50 API URLs and found that 18% had bad redirects before touching app code. Use HTTPie when you want prettier output, and use Postman or Insomnia when you need a full visual workflow.
What Is a HEAD Request?
A HEAD request is like a GET request that forgot its backpack.
It asks the server:
- Are you there?
- What status code do you return?
- What headers do you send?
- How big is the response?
- Is this cached?
- Is there a redirect?
But it does not ask for the response body. No HTML. No JSON. No image file. Just the outer label on the package.
That makes it handy. It is quick. It is quiet. It saves bandwidth. It also makes debugging less painful when an API is being dramatic.
The Basic curl HEAD Command
The classic command is simple:
curl -I https://example.com
The -I flag means send a HEAD request. You can also write it as:
curl --head https://example.com
You might see output like this:
HTTP/2 200
content-type: text/html
cache-control: max-age=3600
server: nginx
content-length: 12560
This tells you a lot. The URL works. It returns 200. It is HTML. It can be cached for one hour. The server is nginx. Nice. Tiny win.
Why HEAD Requests Are Useful for APIs
API bugs often hide in boring places. Headers are one of those places.
A HEAD request can help you check:
- Status codes: Is it
200,301,401,403, or500? - Redirects: Is your API secretly sending clients somewhere else?
- Auth: Is the token accepted?
- Rate limits: Are you close to the request cap?
- Caching: Are bad cache rules causing stale data?
- CORS hints: Are browser calls failing because headers are missing?
Example with an auth token:
curl -I \
-H "Authorization: Bearer YOUR_TOKEN" \
https://api.example.com/v1/profile
If you get 401, your token is probably wrong or expired. If you get 403, the token may be valid but not allowed. If you get 200, breathe. For three seconds. Then check the next thing.
curl HEAD vs curl GET
GET grabs the full thing. HEAD grabs the label.
Use GET when you need the data:
curl https://api.example.com/v1/users
Use HEAD when you only need headers:
curl -I https://api.example.com/v1/users
Here is the simple rule:
- Need JSON? Use
GET. - Need headers? Use
HEAD. - Need to test redirects? Use
HEADwith-L.
curl -I -L https://example.com
The -L flag follows redirects. Without it, curl stops at the first redirect and shows that response. That is useful too. It depends on what you are chasing.
curl HEAD vs HTTPie
curl is everywhere. It is on servers, CI jobs, containers, old laptops, and that one machine nobody wants to reboot.
HTTPie is friendlier. It has cleaner output. It feels more human. It also makes headers easier to read.
HTTPie HEAD request:
http HEAD https://example.com
Or with headers only:
http --headers HEAD https://example.com
With auth:
http HEAD https://api.example.com/v1/profile \
Authorization:"Bearer YOUR_TOKEN"
Honestly, it feels like HTTPie was built for people who got tired of squinting at terminal soup.
Here is the quick match-up:
- curl: Better for scripts, servers, docs, and copy-paste support replies.
- HTTPie: Better for humans, demos, and clean terminal output.
- curl: Almost always installed.
- HTTPie: Usually needs to be installed.
- curl: Has more flags than a pirate convention.
- HTTPie: Easier to read after one coffee, not three.
One Annoying curl Trap
Do not use this unless you know why:
curl -X HEAD https://example.com
It can work. But it can also behave in ways that make you mutter at the screen. The better choice is:
curl -I https://example.com
The -I flag tells curl to handle the request as a HEAD request. Cleaner. Safer. Less weird.
Best curl HEAD Flags for Debugging
These flags are small but mighty.
-I: Send a HEAD request.-L: Follow redirects.-v: Show verbose request and connection details.-s: Silent mode. Good for scripts.-o /dev/null: Ignore body when testing with other methods.-w: Print timing, status, or custom info.
Timing example:
curl -I -w "Status: %{http_code} Time: %{time_total}s\n" \
https://api.example.com/health
This is great for health checks. It is also useful in CI. If the endpoint returns 500, fail the build. If it takes 9 seconds longer than usual, someone should know.
API Debugging Alternatives
curl is not the only tool. Sometimes you need more buttons. Sometimes you need history. Sometimes you just want a pretty request tab because your brain is full.
- HTTPie: Great for readable terminal requests.
- Postman: Good for collections, teams, saved auth, and test flows.
- Insomnia: Clean UI for REST, GraphQL, and environments.
- Bruno: Local-first API client with files you can store in Git.
- Browser DevTools: Best for web app requests and CORS pain.
- wget: Useful for simple downloads and header checks.
- Hurl: Good for text-based API tests in pipelines.
Postman and Insomnia are great when you need to save a flow. Login. Get token. Call endpoint. Refresh token. Call another endpoint. Repeat until the bug gives up.
curl is better when you need one fast truth. Is the server alive? Did the redirect break? Did the cache header change? Show me now.
When To Use Each Tool
Use curl HEAD when:
- You are on a server.
- You need a quick status code.
- You are checking redirects.
- You are writing a script.
- You want fewer moving parts.
Use HTTPie when:
- You want readable output.
- You are testing by hand.
- You hate ugly headers.
- You are teaching someone how APIs work.
Use Postman, Insomnia, or Bruno when:
- You need saved requests.
- You work with a team.
- You test full user flows.
- You need environments like dev, stage, and prod.
A Simple Debugging Flow
Try this order when an API acts up:
- Run
curl -I URL. - Check the status code.
- Check redirects with
-L. - Add auth headers.
- Use
-vif the connection looks odd. - Switch to HTTPie for easier reading.
- Move to Postman or Insomnia for full request flows.
This keeps things simple. Start small. Add tools only when needed. Your future self will be less cranky.
Final Takeaway
curl -I is the fastest way to inspect API headers. It is blunt, useful, and tiny. HTTPie is nicer to read. Postman and Insomnia are better for bigger workflows.
If your API is broken, do not start with a giant dashboard. Start with one command:
curl -I https://api.example.com/health
If that looks wrong, you just saved yourself a long and silly hunt.