# Can I connect to remote database via wireguard, and if so, how?

**URL:** <https://community.fly.io/t/can-i-connect-to-remote-database-via-wireguard-and-if-so-how/16586>\
**Category:** General\
**Tags:** login-only\
**Created:** [November 21, 2023, 8:45pm UTC](https://community.fly.io/t/can-i-connect-to-remote-database-via-wireguard-and-if-so-how/16586 "2023-11-21T20:45:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jphenow](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/jphenow/32/16385_2.png) [@jphenow](https://community.fly.io/u/jphenow)\
**Post date:** [November 21, 2023, 9:44pm UTC](https://community.fly.io/t/can-i-connect-to-remote-database-via-wireguard-and-if-so-how/16586/2 "2023-11-21T21:44:23Z")

</div>

You’re not far off!

You’d want something like a “bastion” host that you run in the AWS account that runs wireguard so you can make a connection to the database.

There is some prior art. You wouldn’t need to do exactly what these folks do but hopefully this illustrates some of the key parts.

> **[IPv6 WireGuard Peering](https://fly.io/blog/ipv6-wireguard-peering/#wireguard-peering)**
>
> Documentation and guides from the team at Fly.io.

> [@Fly.io + RDS & Elasticache](https://community.fly.io/t/fly-io-rds-elasticache/6465/4):
>
> @nate-dwell We’re in the same boat and moved services over using tailscale on fly. Here’s a post I wrote on our setup: [Dockerfile for elixir/phx umbrella app w/ tailscale, overmind, honeymarker](https://community.fly.io/t/dockerfile-for-elixir-phx-umbrella-app-w-tailscale-overmind-honeymarker/5763)

> [@Performance of AWS RDS \<-\> Wireguard bastion \<-\> Fly Private Networking](https://community.fly.io/t/performance-of-aws-rds-wireguard-bastion-fly-private-networking/2322):
>
> I’m trying to decide if I should be deploying my Hasura instances (and possibly Postgres read replicas) via fly or via AWS. I’d personally prefer fly, but then I need to sort out how fly gets access to my AWS VPC where my RDS instance is running. Based on my research that seems like it’s via a [Wireguard bastion host](https://github.com/fly-apps/rds-connector) that I deploy in AWS. Adding a hop like this seems like it would be a bottleneck (for both bandwidth and latency) as well as a single point of failure. But perhaps that’s not a pro…

> **[GitHub - fly-apps/rds-connector: Trivial Terraform example for a WireGuard...](https://github.com/fly-apps/rds-connector)**
>
> Trivial Terraform example for a WireGuard peer to RDS - fly-apps/rds-connector

---

_[View the full topic](https://community.fly.io/t/can-i-connect-to-remote-database-via-wireguard-and-if-so-how/16586)._
