My first attempt to use PostgreSQL:

I have the elephant icon on the top right: running on port 5432.

I want to use LibreOffice as an interface:

  • Connect to an existing database: PostgreSQL
  • Datasource URL: ???

What should I put here? The database will be on the same computer where LibreOffice is running. Tried with localhost:5432 with no success.
By the way, I did not create the database, yet. Can I do it from LibreOffice?

Thank you.

Platform: Mac OSX 10.7 - PostgreSQL 9.2.2 - LibreOffice 4.0

  • You need at least running a db cluster before you can connect. Since you have to connect to a particular database, you can use template1 which is always there or postgres (at least on Debian derivatives) as long as you haven't created yours, yet. Commented Apr 30, 2013 at 23:09

2 Answers 2


From ask.libreoffice, as linked on SuperUser

With the native postgreSQL connector the connection string is a little different. It is not a URL at all, but rather just a text string made up of propertyname=value segments, separated by a space.

The required fields (properties) are, database name and host (or hostaddr). If the postgreSQL database is using a non standard port (5432) then that must be included also.

So, if I want to connect to a database, using the default postgres configuration, named postgres on my local machine the simplest connection string would be: dbname=postgres host=localhost

Now let's say that there is an older postgres engine running using the standard 5432 port and I want to connect to a newer one using port 5433, and that I want to connect with my user name db_user, with a password of libreoffice and I don't want to type that password in each time I connect, then the connection string might look like:

dbname=postgres hostaddr= port=5433 user=db_user password=libreoffice

Note that I've used the hostaddr, instead of host here, bypassing any need to do a DNS lookup.

Finally, with the native connector all options in the connection string are accepted - you can find a full list of those here: PostgreSQL Docs Just remember that it is propertyName=value separated by spaces in Base.


In answer to How do I connect to a PostgreSQL server using LibreOffice Base? on SuperUser, txindoki wrote:

This is not an Internet URL, but it functions similarly. You now need to tell LibreOffice to connect to a specific database on a specific computer:

dbname=mydb host=localhost

Use the name of your database in the dbname part. I used localhost for the host part, since PostgreSQL is on the same computer, but I would need to change that in the event that I want to connect from a remote computer.

Another form of datasource URL is in the format of:

dbname=postgres hostaddr= port=5433 user=db_user password=db_pass

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.