Fly
import { Render, Steps } from "~/components";
This example shows you how to connect Hyperdrive to a Fly Postgres database instance.
1. Allow Hyperdrive access
You can connect Hyperdrive to any existing Fly database by:
- Allocating a public IP address to your Fly database instance
- Configuring an external service
- Deploying the configuration
- Obtain the connection string, which is used to connect the database to Hyperdrive.
```txt
fly ips allocate-v6 --app <pg-app-name>
```
:::note
Cloudflare recommends using IPv6, but some Internet service providers may not support IPv6. In this case, [you can allocate an IPv4 address](https://fly.io/docs/postgres/connecting/connecting-with-flyctl/).
:::
-
Configure an external service by modifying the contents of your
fly.tomlfile. Run the following command to download thefly.tomlfile.fly config save --app <pg-app-name>Then, replace the
servicesandservices.portssection of the file with the followingtomlsnippet:[[services]] internal_port = 5432 # Postgres instance protocol = "tcp" [[services.ports]] handlers = ["pg_tls"] port = 5432 -
Obtain the connection string, which is in the form of:
```txt postgres://{username}:{password}@{public-hostname}:{port}/{database}?options ```
2. Create a database configuration
这篇文档对你有帮助吗?
谢谢你的反馈!