title: Adding port forwarding on an existing vagrant box
body: <p>My running vagrant box (ubuntu, on a OS X Mavericks host) has been running fine.</p>
  
  <p>I am trying to set up pgAdmin from the host, and am having trouble opening a new port for the sql traffic.</p>
  
  <p>I added a line to my Vagrantfile (the last one):</p>
  
  <pre><code>config.vm.network "forwarded_port", guest: 3000, host: 8080   # http
  config.vm.network :forwarded_port, guest: 35729, host: 35729
  config.vm.network "forwarded_port", guest: 5432, host: 7001   # postgres
  </code></pre>
  
  <p>I ran <strong>vagrant provision</strong> and bounced the Vagrant box several times. When it reboots the new port forwarding is not listed:</p>
  
  <pre><code>==&gt; default: Clearing any previously set forwarded ports...
  ==&gt; default: Clearing any previously set network interfaces...
  ==&gt; default: Preparing network interfaces based on configuration...
      default: Adapter 1: nat
      default: Adapter 2: hostonly
  ==&gt; default: Forwarding ports...
      default: 3000 =&gt; 8080 (adapter 1)
      default: 35729 =&gt; 35729 (adapter 1)
      default: 22 =&gt; 2222 (adapter 1)
  ==&gt; default: Running 'pre-boot' VM customizations...
  ==&gt; default: Booting VM...
  ==&gt; default: Waiting for machine to boot. This may take a few minutes...
      default: SSH address: 127.0.0.1:2222
      default: SSH username: vagrant
      default: SSH auth method: private key
      default: Warning: Connection timeout. Retrying...
  ==&gt; default: Machine booted and ready!
  </code></pre>
  
  <p>Curl gives a negative response also:</p>
  
  <pre><code>➜  ~  curl -v 'http://localhost:7001/'
  * Adding handle: conn: 0x7fde1a004400
  * Adding handle: send: 0
  * Adding handle: recv: 0
  * Curl_addHandleToPipeline: length: 1
  * - Conn 0 (0x7fde1a004400) send_pipe: 1, recv_pipe: 0
  * About to connect() to localhost port 7001 (#0)
  *   Trying ::1...
  *   Trying 127.0.0.1...
  *   Trying fe80::1...
  * Failed connect to localhost:7001; Connection refused
  * Closing connection 0
  curl: (7) Failed connect to localhost:7001; Connection refused
  </code></pre>
  
  <p>Related posts:</p>
  
  <p><a href="https://stackoverflow.com/questions/9042330/vagrant-port-forwarding-not-working">Vagrant Port Forwarding not working</a></p>
  
  <p><a href="https://stackoverflow.com/questions/14139017/cannot-connect-to-postgres-running-on-vm-from-host-machine-using-md5-method">Cannot connect to Postgres running on VM from host machine using MD5 method</a></p>