web/docs/guides/debugging/db-studio-fly-io.md
This guide shows you how to connect to your production database on Fly.io and run wasp db studio to inspect or modify your data.
:::warning Working with production data You are about to point your local tooling at the live production database. Make sure to understand the Security Considerations before proceeding. :::
To connect to your production database, you'll need to:
wasp db studioConnect to your Postgres app (replace some-test-db with your actual database app name):
fly postgres connect -a some-test-db
Once connected, list all databases:
\l
Your database name will typically follow the pattern server_name_with_underscores. For example, if your server app is named some-test-server, the database name would be some_test_server.
Type \q to exit the Postgres prompt.
SSH into your database app:
fly ssh console -a some-test-db
Then retrieve the password:
echo $OPERATOR_PASSWORD
Copy this password and type exit to leave the SSH session.
Before opening the tunnel, make sure nothing else is running on port 5432:
wasp db start:::warning Background processes
Even if you close the terminal that was running wasp db start, the Docker container may still be running in the background. Make sure to stop it before proceeding.
:::
Open the tunnel:
fly proxy 5432 -a some-test-db
Keep this terminal tab open and use a new terminal for the following steps.
Edit your .env.server file to point to the production database:
DATABASE_URL=postgres://postgres:<password>@localhost:5432/<db_name>
Replace <password> with the password from Step 2 and <db_name> with the database name from Step 1.
For example:
DATABASE_URL=postgres://postgres:myDatabasePassword@localhost:5432/some_test_server
Now you can run Prisma Studio to browse and edit your production data:
wasp db studio
This will open a web interface where you can view and modify your database records.
.env.server to point to your local database when you're donefly proxy command