title: Troubleshooting access to Flask app in Vagrant guest
body: <p>I have a toy Flask app:</p>
  <pre><code>from flask import Flask
  
  app = Flask(__name__)
  
  @app.route(&quot;/home&quot;)
  def home():
      return &quot;&lt;h1&gt;Home...&lt;/h1&gt;&quot;
  
  @app.route(&quot;/health&quot;)
  def health():
      return &quot;&lt;h1&gt;Healthy&lt;/h1&gt;&quot;
  
  if __name__ == &quot;__main__&quot;:
      app.run(host=&quot;0.0.0.0&quot;, port=5000, debug=True)
  </code></pre>
  <p>.. which is being provisioned using Ansible on a Vagrant guest machine with the following Vagrantfile:</p>
  <pre><code># -*- mode: ruby -*-
  # vi: set ft=ruby :
  
  Vagrant.configure(2) do |config|
    config.vm.box = &quot;geerlingguy/centos7&quot;
    config.vm.provision &quot;ansible_local&quot; do |ansible|
      ansible.playbook = &quot;playbooks/run.yml&quot;
      ansible.tags = &quot;install&quot;
    end
    config.vm.network &quot;forwarded_port&quot;, guest: 5000, host: 5000
    config.vm.provider &quot;virtualbox&quot; do |v|
       v.memory = 2048
       v.cpus = 1
    end
  end
  </code></pre>
  <p>If I <code>vagrant ssh</code> to the guest and launch the flaskapp in with the following:</p>
  <pre><code>export FLASK_APP='/flaskapp/app.py'
  export FLASK_ENV='development'
  cd  /flaskapp
  python3 -m flask run
  </code></pre>
  <p>I can <code>curl 127.0.0.1:5000/home</code> with a successful response.</p>
  <p>However from the Vagrant host (i.e. not the guest where the flask app is running), I cannot access <code>http://localhost:5000/home</code>. Accessing <code>localhost:5000/home</code> (or <code>127.0.0.1:500/home</code>) is:</p>
  <pre><code>The connection was reset
  
  The connection to the server was reset while the page was loading.
  
      The site could be temporarily unavailable or too busy. Try again in a few moments.
      If you are unable to load any pages, check your computer’s network connection.
      If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
  </code></pre>
  <p>I'm using Windows 10, and the guest VMs network config looks like this:</p>
  <p><a href="https://i.stack.imgur.com/QSjiR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QSjiR.png" alt="Guest network config" /></a></p>
  <p>I have tried assigning static ip or assigning an ip dynamically but I cannot access. I am not sure if it's something that I need to add to the <code>/etc/hosts</code> file...</p>
  <p>Can anyone help to identify the issue here and how can I debug this kind of problem?</p>