How to import Geopackages into Postgres/Postgis database?

Hi everyone,

I would like to know how to import a Geopackage file containing raster into a Postgis database. I tried with gdal library “ogr2ogr”.

This is the command line I used:

ogr2ogr -f PostgreSQL PG:"dbname='databasename' host='addr' port='5432' user='x' password='y'" path_name\geopackage_name.gpkg

I use a server Ubuntu 18.04 LAMP with postgres/postgis and I would like to import geopackage from my PC (Ubuntu 19.10 + Qgis + Postgresql 10 + gdal library installed).

Greeting, Giuseppe

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 20, 2019
Accepted Answer


I think that your firewall might be blocking your connections on port 5432, so I would suggest running the command locally from your Droplet.

What you should usually do is:

  • SSH to your Droplet

  • Download data for the whole world or by country. You can download it from here:

To download the package you could run:


Note: the URL might change so it is best to go to the website and get the latest version from there.

  • Create a PostgreSQL database if you don’t already have one.

  • Install the PostGIS extension:

  • Import the data with ogr2ogr with the command that you’ve provided:
ogr2ogr -f PostgreSQL PG:"dbname='databasename' host='addr' port='5432' user='x' password='y'" path_name\geopackage_name.gpkg

Note: You might have to install the ogr2org command if you don’t have it installed already:

npm install ogr2ogr

Hope that this helps!

Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel