Fly proxy to postgres hangs and timeout

I’m trying to access a postgres db locally using fly proxy, but all connections seem to hang and eventually timeout.

Running with debug logs LOG_LEVEL=debug fly proxy 15433:5432 -a <app-name>:

DEBUG Loaded flyctl config from/Users/.../.fly/config.yml
DEBUG determined hostname: "Andreas-Air.lan"
DEBUG determined working directory: "..."
DEBUG determined user home directory: "..."
DEBUG determined config directory: "/Users/.../.fly"
DEBUG ensured config directory exists.
DEBUG ensured config directory perms.
DEBUG cache loaded.
DEBUG config initialized.
DEBUG skipped querying for new release
DEBUG client initialized.
DEBUG app config loaded from ...
DEBUG --> POST https://api.fly.io/graphql

DEBUG {
  "query": "query ($appName: String!) { appbasic:app(name: $appName) { id name platformVersion organization { id slug rawSlug paidPlan } } }",
  "variables": {
    "appName": "..."
  }
}


DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (222.36ms)

DEBUG {
  "data": {
    "appbasic": {
      "id": "...",
      "name": "...",
      "platformVersion": "machines",
      "organization": {
        "id": "...",
        "slug": "personal",
        "rawSlug": "...",
        "paidPlan": false
      }
    }
  }
}

DEBUG --> POST https://api.fly.io/graphql

DEBUG {
  "query": "query ($appName: String!) { appbasic:app(name: $appName) { id name platformVersion organization { id slug rawSlug paidPlan } } }",
  "variables": {
    "appName": "..."
  }
}


DEBUG {}
DEBUG Starting task manager
DEBUG <-- 200 https://api.fly.io/graphql (158.68ms)

DEBUG {
  "data": {
    "appbasic": {
      "id": "...",
      "name": "...",
      "platformVersion": "machines",
      "organization": {
        "id": "...",
        "slug": "personal",
        "rawSlug": "...",
        "paidPlan": false
      }
    }
  }
}

DEBUG --> POST https://api.fly.io/graphql

DEBUG {
  "query": "mutation($input: ValidateWireGuardPeersInput!) { validateWireGuardPeers(input: $input) { invalidPeerIps } }",
  "variables": {
    "input": {
      "peerIps": [
        "..."
      ]
    }
  }
}


DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (159.13ms)

DEBUG {
  "data": {
    "validateWireGuardPeers": {
      "invalidPeerIps": []
    }
  }
}

DEBUG --> POST https://api.fly.io/graphql

DEBUG {
  "query": "mutation($input: ValidateWireGuardPeersInput!) { validateWireGuardPeers(input: $input) { invalidPeerIps } }",
  "variables": {
    "input": {
      "peerIps": [
        "..."
      ]
    }
  }
}


DEBUG {}
DEBUG <-- 200 https://api.fly.io/graphql (153.29ms)

DEBUG {
  "data": {
    "validateWireGuardPeers": {
      "invalidPeerIps": []
    }
  }
}

Proxying local port 15433 to remote [<app>.internal]:5432
DEBUG accepted new connection from: 127.0.0.1:53654
DEBUG failed to connect to target: connect tcp [...]:5432: operation timed out

I launched psql in another shell (psql postgresql://postgres:<password>@localhost:15433/<db>), after a while it times out with:

psql: error: connection to server at "localhost" (::1), port 15433 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 15433 failed: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

and the last debug message appears on the fly proxy logs DEBUG failed to connect to target: connect tcp [...]:5432: operation timed out.

Running fly pg connect -a <app> -d <db> works correctly and opens the remote psql shell, so it seems it’s only a fly proxy problem.

I even recreated the postgres app from scratch, but still getting the same behaviour.

So looks like this issue resolved itself, I tried again after a few hours and now the connection using fly proxy works…

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.