Vagrant Up timing out behind a proxy

(radum) #1

Hi guys,

I’m on a Win7, behind a corporate proxy machine and I’ve cloned the discourse repo, and used vagrant up and I got this error:


Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/omnibus_updater/recipes/default.rb

Connection timed out - connect(2)

Cookbook Trace:
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/omnibus_updater/recipes/set_remote_path.rb:17:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/omnibus_updater/recipes/deb_package.rb:1:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/omnibus_updater/recipes/default.rb:17:in `from_file'

Relevant File Content:

  1:  # RULES
  3:  if(node[:omnibus_updater][:version].nil? && !node[:omnibus_updater][:version_search])
  4:    raise "Omnibus Updater cannot determine version installation request. Please set version of enable version search"
  5:  end
  7:  if(node[:omnibus_updater][:version_search])
  8:    Chef::Log.warn "Omnibus Updater is set to automatically upgrade via search!"
  9:    if(node[:omnibus_updater][:allow_release_clients])

[2013-05-23T12:19:43-04:00] ERROR: Running exception handlers
[2013-05-23T12:19:43-04:00] ERROR: Exception handlers complete
[2013-05-23T12:19:43-04:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-05-23T12:19:43-04:00] FATAL: Errno::ETIMEDOUT: Connection timed out - connect(2)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

I thought is from the proxy and I used chef.proxy in the vagrant file but same issue. I’ve tested the same thing on a machine that is not behind a proxy and worked perfect.

Is there a way to make it work also behind a corporate proxy, or I’m a total noob and I’m missing something?

(Neil Lalonde) #2

I have no idea… Maybe the vagrant google group can help? Google Groups

(radum) #3

Thanks @Neil I’ve searched almost everywhere for a fix, no solution. I will start asking now and I will get back if I find something.

(radum) #4

I think I found a way that could solve this problem. Not sure if it’s the best way or if there is a different way to do it better, I haven’t found one anyways.

I created a new empty recipe called chef_proxy and I’ve added this recipe to the folder with the other ones in /chef/cookbooks/.

I’ve added a default.rb file that only contains:

ENV['http_proxy'] = "http://your-proxy-server:port"

It basically tells chef to set an environment variable called http_proxy with that value.

In the Vagrantfile I’ve added the recipe to be loaded first before all the others

chef.add_recipe "chef_proxy"

And run vagrant up after.

Surprisingly it worked this time and it installed everything. After that I had to ssh the vagrant box and run bundle install but it will fail fetching your dependencies from git. And this is because git is not configured to use a proxy. So I’ve run git config --global http.proxy http://your-proxy-server:port and bundle install again.

And it worked :smile: then run:

bundle exec rake db:migrate
bundle exec rails s

a couple of minutes later and the server is up and running.

So if you are behind a proxy server that is restrictive and you can’t get this to work, here it is, my crappy solution.

(Teemu Matilainen) #5


Late to the party, but you can also use vagrant-proxyconf plugin which can be used for configuring (hopefully) everything on the VM to use the specified proxy.

The plugin is installed in the standard Vagrant way:

vagrant plugin install vagrant-proxyconf

Most probably you want to use the same configuration for all machines, so you can use $HOME/.vagrant.d/Vagrantfile in your local machine:

Vagrant.configure("2") do |config|
  config.proxy.http  = "http://your-proxy-server:port"
  config.proxy.https = "http://your-proxy-server:port"
  # other configuration...

It is also possible to use environment variables. See the documentation for more information.

All feedback welcome! =)

(radum) #6

Hi @tmatilai I just tested the plugin and works like a charm.

I’m not really sure how to use the env variables on a Windows machine but adding the config to the Discourse Vagrantfile worked ok.

This is a much better solution anyways. Thanks