title: Failed to connect to database on Minikube
body: <p>I am new in Kubernetes and trying to deploy an application that connects to a postgres deployment in Minikube. Before runing the deployments on Minikube, I can run the application outside Minikube on my computer operating system without any problems. But when I run the deployments on Minikube, the application works neither in Minikube nor outside the Minikube. I get these error for each:</p>
  <p>error while running application inside Minikube</p>
  <pre><code>psycopg2 ERROR: connection to server at &quot;localhost&quot; (127.0.0.1), port 5432 failed: Connection refused
          Is the server running on that host and accepting TCP/IP connections?
  connection to server at &quot;localhost&quot; (::1), port 5432 failed: Cannot assign requested address
          Is the server running on that host and accepting TCP/IP connections?
   on line number: 46
  psycopg2 traceback: &lt;traceback object at 0x7f6ce1d3ef40&gt; -- type: &lt;class 'psycopg2.OperationalError'&gt;
  
  extensions.Diagnostics: &lt;psycopg2.extensions.Diagnostics object at 0x7f6ce1d1c5b0&gt;
  pgerror: None
  pgcode: None
  </code></pre>
  <p>error while running outside Minikube:</p>
  <pre><code>connection to server at &quot;localhost&quot; (::1), port 5432 failed: Cannot assign requested address
  Is the server running on that host and accepting TCP/IP connections?
  </code></pre>
  <p>What is here problematic?</p>