Curl to postgres in separate vagrant environment
<p>I am attempting to set up an environment with two vagrant machines. One contains an application (portal) and a postgres database instance and the other contains an API (api) from which I wish to run curl commands to query the portal database.</p>

<p>Through using private network in vagrant</p>

<p>Portal Environment </p>

<p>Vagrantfile:</p>

<pre><code>Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.network "forwarded_port", guest: 3000, host: 3000
  config.vm.network "forwarded_port", guest: 5432, host: 5432         -- Fix
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.synced_folder "../Base", "/Base"
  config.vm.synced_folder "../alacrity-v2-api", "/API"
end
</code></pre>

<p>Database.yml</p>

<pre><code>development: &amp;development
  adapter: postgresql
  database: payments_development
  username: payments
  password: payments
  host:     localhost
  port:     5432
  pool: 10
  reconnect: true
  min_messages: warning
</code></pre>

<p>API Environment</p>

<p>Vagrantfile:</p>

<pre><code>Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.network "forwarded_port", guest: 3002, host: 3002
  config.vm.network "private_network", ip: "192.168.33.11"     --Fix
  config.vm.synced_folder "../Base", "/Base"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
  end

end
</code></pre>

<p>Database.yml</p>

<pre><code>development: &amp;development
  adapter: postgresql
  database: chsh
  host: 192.168.33.10
  port: 3000
  username: payments
  password: payments
  database: payments_development
  pool: 10
</code></pre>

<p>Now when i run my curl command (removed basic auth password for security reasons):</p>

<pre><code>curl -v -L http://localhost:9292/v2.2/ -H "Authorization: Basic ??????????????????????????"
</code></pre>

<p>The following is returned in my API environment </p>

<pre><code>* About to connect() to localhost port 9292 (#0)
*   Trying 127.0.0.1... connected
&gt; GET /v2.2/ HTTP/1.1
&gt; User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
&gt; Host: localhost:9292
&gt; Accept: */*
&gt; Authorization: Basic emFpbmFnZ3JlZ180MTZfbGl2ZTo4b3Jlc3B1Y3Jv
&gt;
&lt; HTTP/1.1 500 Internal Server Error
&lt; Content-Length: 6866
&lt;
Puma caught this error: received invalid response to SSL negotiation: H
 (PG::ConnectionBad)
</code></pre>

<p>While in my Portal environment I get this:</p>

<pre><code>Invalid request: Invalid HTTP format, parsing fails.
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/request.rb:84:in `execute'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/request.rb:84:in `parse'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/connection.rb:39:in `receive_data'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run_machine'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/backends/base.rb:73:in `start'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/server.rb:162:in `start'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/handler/thin.rb:13:in `run'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/rack-1.4.7/lib/rack/server.rb:268:in `start'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22/lib/rails/commands/server.rb:70:in `start'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22/lib/rails/commands.rb:55:in `block in &lt;top (required)&gt;'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22/lib/rails/commands.rb:50:in `tap'
        /home/vagrant/.rvm/gems/ruby-2.3.0/gems/railties-3.2.22/lib/rails/commands.rb:50:in `&lt;top (required)&gt;'
        script/rails:6:in `require'
        script/rails:6:in `&lt;main&gt;'
</code></pre>

<p>Can anyone help me understand what the issue is or how I could go about diagnosing the problem.</p>