
# 

Migrate from Heroku to Supabase

## 

Migrate your Heroku Postgres database to Supabase.

* * *

Supabase is one of the best [free alternatives to Heroku Postgres](/alternatives/supabase-vs-heroku-postgres). This guide shows how to migrate your Heroku Postgres database to Supabase. This migration requires the [pg\_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and [psql](https://www.postgresql.org/docs/current/app-psql.html) CLI tools, which are installed automatically as part of the complete Postgres installation package.

Alternatively, use the [Heroku to Supabase migration tool](https://migrate.supabase.com/) to migrate in just a few clicks.

## Quick demo[#](#quick-demo)

## Retrieve your Heroku database credentials [#](#retrieve-heroku-credentials)

1.  Log in to your [Heroku account](https://heroku.com) and select the project you want to migrate.
2.  Click **Resources** in the menu and select your **Heroku Postgres** database.
3.  Click **Settings** in the menu.
4.  Click **View Credentials** and save the following information:
    *   Host (`$HEROKU_HOST`)
    *   Database (`$HEROKU_DATABASE`)
    *   User (`$HEROKU_USER`)
    *   Password (`$HEROKU_PASSWORD`)

## Retrieve your Supabase connection string [#](#retrieve-supabase-connection-string)

1.  If you're new to Supabase, [create a project](/dashboard).
2.  Get your project's Session pooler connection string from your project dashboard by clicking [Connect](/dashboard/project/_?showConnect=true&method=session).
3.  Replace \[YOUR-PASSWORD\] in the connection string with your database password. You can reset your database password on the [Database Settings page](/dashboard/project/_/database/settings) if you do not have it.

## Export your Heroku database to a file [#](#export-heroku-database)

Use `pg_dump` with your Heroku credentials to export your Heroku database to a file (e.g., `heroku_dump.sql`).

```
1pg_dump --clean --if-exists --quote-all-identifiers \2 -h $HEROKU_HOST -U $HEROKU_USER -d $HEROKU_DATABASE \3 --no-owner --no-privileges > heroku_dump.sql
```

## Import the database to your Supabase project [#](#import-database-to-supabase)

Use `psql` to import the Heroku database file to your Supabase project.

```
1psql -d "$YOUR_CONNECTION_STRING" -f heroku_dump.sql
```

## Additional options[#](#additional-options)

*   To only migrate a single database schema, add the `--schema=PATTERN` parameter to your `pg_dump` command.
*   To exclude a schema: `--exclude-schema=PATTERN`.
*   To only migrate a single table: `--table=PATTERN`.
*   To exclude a table: `--exclude-table=PATTERN`.

Run `pg_dump --help` for a full list of options.

*   If you're planning to migrate a database larger than 6 GB, we recommend [upgrading to at least a Large compute add-on](/docs/guides/platform/compute-add-ons). This will ensure you have the necessary resources to handle the migration efficiently.
    
*   We strongly advise you to pre-provision the disk space you will need for your migration. On paid projects, you can do this by navigating to the [Compute and Disk Settings](/dashboard/project/_/settings/compute-and-disk) page. For more information on disk scaling and disk limits, check out our [disk settings](../../compute-and-disk/index.md#disk) documentation.
    

## Enterprise[#](#enterprise)

[Contact us](https://forms.supabase.com/enterprise) if you need more help migrating your project.
