Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Problem. Following command line

knife bootstrap -r 'recipe[chef-client]' -x user -p password --sudo


Bootstrapping Chef on
WARNING: Failed to connect to -- Errno::ECONNREFUSED: Connection refused - connect(2)

Expected that this command will succeed and after it

knife node list

will return


SSH server is working fine on localhost and ssh user@ -p password works as expected.

share|improve this question

migrated from May 6 '11 at 7:36

This question came from our site for professional and enthusiast programmers.

Looks like the problem with the invocation is that you specified the password with the -p option, which knife bootstrap uses to specify an alternate ssh port. You wanted to use the -P (capital P), which the right option for specifying the password to the bootstrap command.

And, as Justin has indicated, bootstrap is likely not technically necessary if you already have chef installed to the point where you can run 'knife' commands. You should be able to fire off a 'chef-client' to enroll your node to the server (perhaps needing the validation key with -K option, if it's not already installed/available in /etc/chef). Once registered to your server, you can issue knife node run_list add commands to add the appropriate roles/recipes to the runlist, then invoke another chef-client to get it to take effect. Then again, bootstrap does it all in one command, so it's not a terrible option.

share|improve this answer

And you must add the IP and NODENAME(Hostname) to /etc/hosts: NODENAME

And then split % knife bootstrap -r 'recipe[chef-client]' -x user -p password --sudo to two steps:

Step 1:

% knife bootstrap IP_ADDRESS -x ubuntu -P PASSWORD --sudo

Step 2:

% knife ssh name:NODENAME -x ubuntu -P PASSWORD "sudo chef-client"
share|improve this answer

If you're getting a connection refused, then an SSH connection could not be opened because either:

  • SSH is not running on the system.
  • A firewall rule is blocking access to port 22.
  • SSH is running on a port other than 22.

That said, "knife bootstrap" is intended to be used to set up remote systems with Ruby/RubyGems, install Chef and configure it to connect to a configured chef server (from your local knife configuration). For more information about the "knife bootstrap" command, see:

Also, the node name will be the detected fully qualified domain name (typically output of hostname -f), unless specified with -N NODE_NAME.

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.