Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following curl command

curl -X POST -w "\nRESULT CODE:%{http_code}\n" --insecure --header "Content-Type:application/json" --user robot-midc:1ZSXM7 -d @table.json

and I receive the following response

<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>

hmmm, how do I check the actual http code, was it a 302 as curl docs claim they follow redirects so I am not sure what is going on?

thanks, Dean

hmmm, maybe this is a bug in that curl doesn't follow http to https redirect like browsers do???? My issue was simply that the load balancer always redirects to https and I had http on the line odd, it would be nice for curl to give a better error in that it doesn't redirect to https (ie. doesn't follow all redirects like the documentation states).

share|improve this question
up vote 3 down vote accepted

Pass -L to cURL and it will follow the 302.

share|improve this answer

Add -v to curl to see the actual header responses.
And by default it doesn't follow redirects, add -L to also follow redirects, but (from the man page):

When authentication is used, curl only sends its credentials  to  the
initial  host.  If a redirect takes curl to a different host, it
won't be able to intercept the user+password. See  also  --location-trusted
on how to change this. 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.