<p>I'm following <a href="https://hasura.io/docs/1.0/graphql/manual/deployment/kubernetes/index.html#step-1-get-the-kubernetes-deployment-and-service-files" rel="nofollow noreferrer">this tutorial</a> to connect a hasura kubernetes pod to my local postgres server.</p>

<p>When I create the deployment, the pod's container fails to connect to postgres (CrashLoopBackOff and keeps retrying), but doesn't give any reason why. Here are the logs:</p>

<pre><code>{"type":"pg-client","timestamp":"2020-05-03T06:22:21.648+0000","level":"warn","detail":{"message":"postgres connection failed, retrying(0)."}}
</code></pre>

<p>My deployment.yaml:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hasura
    hasuraService: custom
  name: hasura
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hasura
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: hasura
    spec:
      containers:
      - image: hasura/graphql-engine:v1.2.0
        imagePullPolicy: IfNotPresent
        name: hasura
        env:
        - name: HASURA_GRAPHQL_DATABASE_URL
          value: postgres://USER:@localhost:5432/my_db
        - name: HASURA_GRAPHQL_ENABLE_CONSOLE
          value: "true"
        ports:
        - containerPort: 8080
          protocol: TCP
        resources: {}
</code></pre>

<p>I'm using <code>postgres://USER:@localhost:5432/MY_DB</code> as the postgres url - is "localhost" the correct address here?</p>

<p>I verified that the above postgres url works when I try (no password):</p>

<pre><code>&gt; psql postgres://USER:@localhost:5432/my_db
psql (12.2)
Type "help" for help.

&gt; my_db=#
</code></pre>

<p>How else can I troubleshoot it? The logs aren't very helpful...</p>

tbd_
<p>If I got you correctly, the issue is that the Pod (from  "inside" the Minikube ) can not access Postgres installed on Host machine (the one that runs Minikube itself) via <code>localhost</code>. </p>

<p>If that is the case, please check <a href="https://stackoverflow.com/questions/60882006/how-to-connect-to-mongodb-running-on-localhost-from-minikube/60986502#60986502">this thread</a> .</p>

<blockquote>
  <p>... Minikube VM can access your host machine’s localhost on 192.168.99.1 (127.0.0.1 from Minikube would still be a Minicube's localhost).</p>
</blockquote>

<p>Technically, for the Pod the <code>localhost</code> is Pod itself. The Host machine and Minikube are connected via bridge. You can find out exact ip addresses and routes with the <code>infconfig</code> and <code>route -n</code> on your Minikube Host.</p>
