I'm trying to use knife ec2 server create to automatically launch ec2 instances for the first time, but I'm getting "ERROR: Excon::Errors::BadRequest: Expected(200) <=> Actual(400 Bad Request)".

When using knife ec2 server list the list of existing servers is returned, which means the AWS IDs in .chef/knife.rb are correct.

I checked AMI ID using Ubuntu's AMI Finder, and tried different combinations of all other parameters, so can't figure out what's wrong.

I'm using is:

knife ec2 server create \
    -r "role[memcached]" -I ami-d0f89fb9 -f m1.small \
    -i mysshkey.pem --ssh-user newuser \
    --region us-east-1b -Z us-east-1b

(there is a Chef role called memcached, there's a file in the local directory called mysshkey.pem)

Environment: Win7, Git 1.8.1.msysgit.1, Chef/Knife 11.4.4. I will try later doing the same from a Linux workstation, so I can isolate if the problem is the environment, or paramenters, or AWS credentials.

Any idea how to troubleshoot knife ec2 scripts?

  • Just as a random aside, you will also see that same error if you hit your EC2 instance cap like I just did. – MattC Jul 11 '13 at 3:24

I finally found the problem.

The parameter -i <AWS_SSH_ID> is not used to specify the SSH key itself, but the security name of the SSH Pair Key used when you created your credentials within AWS.

After adjusting this, knife ec2 create started to work properly.


us-east-1b is not a valid EC2 region. Try us-east-1.

  • Same thing. Also tried using Knife under ubuntu 13.04, and exact same error. – Gui Ambros May 23 '13 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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