---
title: "fly.io - Dump your PostgreSQL DB locally - Daniel Tello"
description: "Step-by-step tutorial on how to dump your PostgreSQL database from fly.io to your local computer. Quick guide for developers using fly.io hosting."
url: https://tello.io/blog/flyio-dump-your-postgresql-db-locally/
author: Daniel Tello
lang: es
date_modified: 2026-05-31
---

# fly.io - Dump your PostgreSQL DB locally

Tutorial: How to dump your PostgreSQL DB to your local computer

## Step 1: Proxy the PostgreSQL port

First, you need to proxy the PostgreSQL port from your fly.io app to your local machine. Open a terminal and run:

```bash
fly proxy 15432:5432 -a your-app-db
```

This command forwards port 5432 from your fly.io PostgreSQL instance to port 15432 on your local machine. Keep this terminal open while you perform the dump.

## Step 2: Dump the database

Open a new terminal window and run pg_dump to create a backup of your database:

```bash
pg_dump -h localhost -p 15432 -U postgres your_database_name > dump.sql
```

This will create a file called dump.sql with the complete database dump. You may be prompted for the PostgreSQL password.

## Step 3: Close the proxy

Once the dump is complete, go back to the first terminal and close the proxy by pressing Ctrl+C.

## Step 4: Restore locally

To restore the dump into your local PostgreSQL database, run:

```bash
psql -h localhost -U postgres -d your_local_database < dump.sql
```

Make sure your local PostgreSQL server is running and the target database exists before running this command. You can create a new database with:

```bash
createdb -h localhost -U postgres your_local_database
```
