Vagrant: Working with a proxy

If you are using vagrant in an environment where a proxy is required (typically behind a corporate firewall), then very often this will cause a problem downloading the box file required to start up your virtual machine.

The init phase will generally work fine. e.g

$ vagrant init ubuntu/trusty64

A 'Vagrantfile' has been placed in this directory. You are now
ready to 'vagrant up' your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
'vagrantup.com' for more information on using Vagrant.

Nothing that indicates a problem there.

However when you try and run vagrant up is where the problems start. You may start to see problems like the following.

$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and in stall...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'ubuntu/trusty64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on Vagrant Cloud, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://vagrantcloud.com/ubuntu/trusty64"]
Error: Could not resolve host: (nil); Host not found

To resolve this you need to define your proxy host and port in an environment variable.

*nix base systems

export HTTP_PROXY=http://my_poxy_host:3030
export HTTPS_PROXY=http://my_poxy_host:3030

Replace the values about with your proxy hostname and address appropriately

Try running “vagrant up” again. If it works then great 🙂

If your proxy is invalidating the certificate, then you will probably get something similar to the following:-


$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'ubuntu/trusty64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on Vagrant Cloud, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://vagrantcloud.com/ubuntu/trusty64"]
Error: SSL certificate problem: self signed certificate in certificate chain
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

To resolve this you need to tell Vagrant to ignore the SSL certificate when downloading files. In the directory where you performed “vagrant init” there should be a file called “Vagrantfile”. Open this file in your favourite editor.

Just before the end of the file and the line that contains “end” add the following option:-

config.vm.box_download_insecure=true

You should now be able to correctly download your vagrant box and continue.

$ vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty64'
default: URL: https://vagrantcloud.com/ubuntu/trusty64
==> default: Adding box 'ubuntu/trusty64' (v14.04) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.