title: Sending http request to server running on a VirtualBox linux machine from the host machine
body: <p>I currently am developing a REST server using Microsoft's cpprestsdk called Casablanca.</p>
  
  <p>I have the server running on a linux virtual machine using Oracle's VirtualBox.</p>
  
  <p>I have the VM set up to use bridged adapter networking, and can successfully SSH into the machine so I know that it is possible to send an http request to my server.</p>
  
  <p>I have the endpoint of my server currently set to: </p>
  
  <pre><code>http://localhost:4200/api"
  </code></pre>
  
  <p>See the code in my main.cpp below:</p>
  
  <pre><code>int main() {
      cout &lt;&lt; "Starting Server" &lt;&lt; endl;
  
      TransactionController server;
      server.setEndpoint("http://localhost:4200/api");
      server.initHandlers();
  
      try {
          server.openServer().wait();
          cout &lt;&lt; "Server listening at: " &lt;&lt; server.getEndpoint() &lt;&lt; endl;
  
          // figure out how to keep server running without this?
          while (true);
      }
      catch(exception &amp;e) {
          cout &lt;&lt; "--- ERROR DETECTED ---" &lt;&lt; endl;
          cout &lt;&lt; e.what() &lt;&lt; endl;
      }
  
  
      // this doesn't get reached bc of the while(true)
      server.closeServer().wait();
  
      return 0;
  }
  </code></pre>
  
  <p>(I know that this isn't the cleanest implementation, but I am just trying to get something off the ground so I can test functionality, feel free to comment on how I can improve that code snippet if you have anything to say)</p>
  
  <p>So if I log into my VM and do a curl GET request on the guest machine it completes successfully and I receive my response as intended.</p>
  
  <p>Example curl:</p>
  
  <pre><code>curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:4200/api
  </code></pre>
  
  <p>Now my question is, how can I do the same request but from my host computer, using an HTTP client such as Postman or Advanced Rest Client?</p>
  
  <p>I am not sure what I would put as the request URL when attempting to query my server running on my guest machine from my host machine.</p>
  
  <p>Using ifconfig I know my ip address of the guest machine is:</p>
  
  <pre><code>10.0.0.157
  </code></pre>
  
  <p>I can SSH into my VM using this address, so I know this is the correct address of my guest machine.</p>
  
  <p>I do not know how I can send my http requests to this machine that is running my server, however.</p>
  
  <p>I am not an expert in networking, or casablanca for that matter, so any guidance or pointers in the right direction would be greatly appreciated. Thank you for your time!</p>