Install PostgreSQL 11 and PgAdmin4 on Ubuntu 18.04

Filed Under: Ubuntu

In this guide, you will learn how to install PostgreSQL 11 and PgAdmin4 on Ubuntu 18.04 LTS.


PostgreSQL is a free and open source cross-platform Relational Database Management System (RDBMS). It is widely used by developers in the development environment and in production environments as well. PostgreSQL 11 was released in November 2018 and comes with a wealth of new and exciting features.


PgAdmin 4 is a free and open source web-based administration and development platform that helps users to administer, manage and monitor Postgres databases in a graphical manner. Let’s now dive in and see how we can install the two.

Install PostgreSQL on Ubuntu

Step 1: Importing GPG key & adding PostgreSQL APT repository

To get started, begin by importing the GPG key for the PostgreSQL packages. Use the command below to download the CA certificates.

$ sudo apt install wget ca-certificates

Sample Output

Install Wget Ca Certificates

Next, run the command below to import the GPG key to your system.

$ wget --quiet -O - | sudo apt-key add -


Add Key Ubuntu

Step 2: Adding PostgreSQL apt repository to System

Once done with importing the GPG key, append the PostgreSQL apt repository on your system.

$ sudo sh -c 'echo "deb `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

Step 3: Installing PostgreSQL 11 on Ubuntu

Before installing PostgreSQL 11, first, update the system repositories as shown.

$ sudo apt-get update

Next, run this command to install PostgreSQL 11.

$ sudo apt-get install postgresql postgresql-contrib


Install PostgreSQL on Ubuntu

Step 4: Connecting to PostgreSQL 11

By default, PostgreSQL database server creates a user ‘postgres‘ having the role ‘postgres‘.

To connect to the PostgreSQL 11 server, log in to your system and run the command below to change to the postgres user.

$ sudo su - postgres

Postgres User Created

NOTE: The ‘postgres’ user’s password is disabled by default.

Finally , to connect to the PostgreSQL 11 database server use the psql command as shown.



Psql command

To check login information, run the command below.

postgres-# \conninfo


PostgreSQL Connection Info

Installation of PgAdmin4

To begin the installation of PgAdmin4, run the command below.

$ sudo apt-get install pgadmin4 pgadmin4-apache2


Install Pgadmin4

During the installation process, you will be prompted for an email address as shown below. This is the email address you will use to log in to the PgAdmin4 interface.
Provide an email address of your choice

Pg4admin User Email

Next, you will be prompted for your password. Provide your preferred password. The system will then proceed to wrap up the installation of PgAdmin4.

Pgadmin4 Provide Initial Password
Great ! At this point you have successfully installed PgAdmin4.

Connecting to PgAdmin4

Now that we have successfully installed PgAdmin4, it’s time now to connect to it. Open your browser and browse your server’s IP address as shown


In our example, the URL is:

Pgadmin4 Login Page

You will see the following login page. Enter the email address and password that you provided during the setup of PgAdmin4 and hit ‘Login’.

You will finally be presented with the PgAdmin4 dashboard as shown below.

Pgadmin4 Dashboard

With the dashboard, you can now create database server instances as well as monitor the performance of your databases.

This wraps up the topic of how to install PostgreSQL 11 and PgAdmin4 on Ubuntu server. Feel free to reach out to us with your feedback and share the article on your social platforms.


  1. Manish says:

    After installation, /pgadmin4 login says
    Bad Request
    The CSRF tokens do not match.

    Any solution?

  2. Savitha mark says:

    I am new for coding, I followed all the steps finally i gave my IP address, but its giving an error saying ” site cant be reached”. please help me with this

  3. jhan says:

    Hi , it doest not work for me, it says that apache2 is not active , my be because i have nginx installed

  4. Farid says:

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package pgadmin4 is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package ‘pgadmin4’ has no installation candidate
    E: Unable to locate package pgadmin4-apache2

  5. Brent WG says:

    Hi: Quick question. Do I need to have PostgreSQL server installed on my workstation, in order to install pgAdmin4? The reason I ask is that I only want to use it to connect to remote databases. I have no intention of running a database server on my workstation. Please advise. Thanks very much for these instructions.


    1. Pankaj says:

      No, I don’t think so. You can install pgAdmin4 without installing PostgreSQL.

  6. Юрий says:

    Many thanks for this article. It’s the best article for me. Good luck! 🙂

  7. Jorge Bautista says:

    Hi, I think there’s a typo on Step 3. Instead of sudo apt-update is sudo apt-get update

    1. Pankaj says:

      Thanks for noticing it, I have fixed it.

    2. Liyakhat Ali says:

      What’s the diff b/w apt and apt-get ??

Comments are closed.

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors