This plugin manages databases that are shared with other services on Shuttle. Your database will share a postgres server with other users, but it will not be accessible by other users.


Add shuttle-shared-db to the dependencies for your service. Every type of shareable database is behind the following feature flag and attribute path. *-rustls feature enables rustls-based implementation, otherwise some flavour of native-tls is used.

EngineFeature flagsAttribute path
Postgrespostgres, postgres-rustlsshuttle_shared_db::Postgres


local_uristrNoneRather connect cargo shuttle run to this database and don’t spin up a Docker instance of the database

When setting the local_uri you can also insert secrets from Secrets.toml using string interpolation. To insert the PASSWORD secret, pass it in like this:

async fn poem(
        local_uri = "postgres://postgres:{secrets.PASSWORD}@localhost:16695/postgres"
    )] pool: PgPool,
) -> ShuttlePoem<impl poem::Endpoint> { ... }
If you are interpolating a secret from, you need to set the same secret in Secrets.toml to a empty string so that this step does not crash in deployment.


The Shuttle poem main function below uses the [shuttle_shared_db::Postgres] attribute macro to provision a shared postgres database, which can be accessed using a pre-configured, authenticated sqlx Pool.
async fn poem(
    #[shuttle_shared_db::Postgres] pool: PgPool,
) -> ShuttlePoem<impl poem::Endpoint> {

    let app = Route::new()
        .at("/todo", post(add))
        .at("/todo/:id", get(retrieve))


The full example can be found on GitHub