🇦🇺 Hello Australia! Sydney region is officially live on Neon.Sign Up

Import data from Heroku

This guide describes how to import your data from Heroku Postgres to Neon.

The instructions assume that you have installed the Heroku CLI, which is used to transfer data from Heroku. For installation instructions, see The Heroku CLI.

To migrate your data from Heroku to Neon:

  1. Create a Neon project and copy the connection string
  2. Retrieve your Heroku app name and database name
  3. Import your data
  4. Verify that your data was imported

Create a Neon project and copy the connection string

  1. Navigate to the Projects page in the Neon Console.

  2. Click New Project.

  3. Specify your project settings and click Create Project.

  4. After creating a project, you are directed to the Neon Dashboard, where a connection string with your password is provided under Connection Details. Copy the connection string. It is required to import your data from Heroku.

    The example connection string used the instructions that follow is:

    postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname

Retrieve your Heroku app name and database name

  1. Log in to Heroku and select the project you want to import data from.
  2. Select Overview and copy the name of the Heroku Postgres database, which appears under Installed add-ons.
  3. Click Settings and copy your Heroku App Name.

note

You can also retrieve the Heroku Postgres database name using the following Heroku CLI command:

heroku pg:links --app <app>

where <app> is the Heroku App Name.

For example:

$ heroku pg:links --app thawing-wave-57227=== postgresql-trapezoidal-48645

Import your data

From your terminal, run the following Heroku CLI command:

heroku pg:pull --app [app] [heroku-pg-database] [neon-connection-string]

where:

  • [app] is the name of the Heroku app
  • [heroku-pg-database] is the name of the Heroku PostgreSQL database
  • [neon-connection-string] is the Neon connection string

For example:

$ heroku pg:pull --app thawing-wave-57227 postgresql-trapezoidal-48645 postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbnameheroku-cli: Pulling postgresql-trapezoidal-48645 ---> postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbnamepg_dump: last built-in OID is 16383pg_dump: reading extensionspg_dump: identifying extension memberspg_dump: reading schemaspg_dump: reading user-defined tablespg_dump: reading user-defined functionspg_dump: reading user-defined typespg_dump: reading procedural languagespg_dump: reading user-defined aggregate functionspg_dump: reading user-defined operatorspg_dump: reading user-defined access methodspg_dump: reading user-defined operator classespg_dump: reading user-defined operator familiespg_dump: reading user-defined text search parserspg_dump: reading user-defined text search templatespg_dump: reading user-defined text search dictionariespg_dump: reading user-defined text search configurationspg_dump: reading user-defined foreign-data wrapperspg_dump: reading user-defined foreign serverspg_dump: reading default privilegespg_dump: reading user-defined collationspg_dump: reading user-defined conversionspg_dump: reading type castspg_dump: reading transformspg_dump: reading table inheritance informationpg_dump: reading event triggerspg_dump: finding extension tablespg_dump: finding inheritance relationshipspg_dump: reading column info for interesting tablespg_dump: finding the columns and types of table "public.customer"pg_dump: finding the columns and types of table "public.order"pg_dump: flagging inherited columns in subtablespg_dump: reading indexespg_dump: reading indexes for table "public.customer"pg_dump: reading indexes for table "public.order"pg_dump: flagging indexes in partitioned tablespg_dump: reading extended statisticspg_dump: reading constraintspg_dump: reading foreign key constraints for table "public.customer"pg_dump: reading foreign key constraints for table "public.order"pg_dump: reading triggerspg_dump: reading triggers for table "public.customer"pg_dump: reading triggers for table "public.order"pg_dump: reading rewrite rulespg_dump: reading policiespg_dump: reading row-level security policiespg_dump: reading publicationspg_dump: reading publication membershippg_dump: reading subscriptionspg_dump: reading large objectspg_dump: reading dependency datapg_dump: saving encoding = UTF8pg_dump: saving standard_conforming_strings = onpg_dump: saving search_path =pg_dump: saving database definitionpg_dump: dumping contents of table "public.customer"pg_restore: connecting to database for restorepg_dump: dumping contents of table "public.order"pg_restore: creating SCHEMA "heroku_ext"pg_restore: creating TABLE "public.customer"pg_restore: creating TABLE "public.order"pg_restore: processing data for table "public.customer"pg_restore: processing data for table "public.order"pg_restore: creating CONSTRAINT "public.customer customer_pkey"pg_restore: creating CONSTRAINT "public.order order_pkey"pg_restore: creating FK CONSTRAINT "public.order order_customer_id_fkey"heroku-cli: Pulling complete.

Verify that your data was imported

  1. Log in to the Neon Console.
  2. Select the Neon project that you transferred data to.
  3. Select the Tables tab.
  4. In the sidebar, verify that your database tables appear under the Tables heading.

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. Neon Pro Plan users can open a support ticket from the console. For more detail, see Getting Support.

Last updated on

Edit this page
Was this page helpful?