46

I just installed PostgreSQL and I am trying to install pgdmin4, but whenever I run the command below to install pgadmin4 and pgadmin4-apache2

sudo apt install pgadmin4 pgadmin4-apache2

I often get the error

E: Package 'pgadmin4' has no installation candidate

E: Unable to locate package pgadmin4-apache2

I have tried out a lot of solutions, but none seems to do the trick. I need some help.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143

8 Answers8

138

Here's how I solved the issue;

The issue arises because the repository for pgadmin has not been added to your local machine. To solve the issue, do the following below;

Note: This should work in Ubuntu 16.04 (Xenial), Ubuntu 18.04 (Bionic), Ubuntu 19.10 (Eoan), Ubuntu 20.04 (Focal), Debian 9 (Stretch) and Debian 10 (Buster)

Install the public key for the repository (if not done previously):

curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add

Create the repository configuration file:

sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

Choose the Installation method that you want:

  • Install pgAdmin (for both desktop and web modes):

    sudo apt install pgadmin4
    
  • Install pgAdmin (for desktop mode only):

    sudo apt install pgadmin4-desktop
    
  • Install pgAdmin (for web mode only):

    sudo apt install pgadmin4-web 
    

You can configure the webserver, if you installed pgadmin for web mode:

sudo /usr/pgadmin4/bin/setup-web.sh

Resources: pgAdmin 4 (APT)

starball
  • 20,030
  • 7
  • 43
  • 238
Promise Preston
  • 24,334
  • 12
  • 145
  • 143
  • I just upgraded from ubuntu 18.04 to 19.10 and my pgadmin got removed and when I tried to installed it by your way it's saying that `Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming.` Does that mean that pgadmin4 is not supported on ubuntu 19.10. – Sarthak Kumar Feb 24 '20 at 00:57
  • I have not tried installing Pgadmin4 on Ubuntu 19.10. I think you should check the supported operating systems on Pgadmin4's website to see if Ubuntu 19.10 is supported. – Promise Preston Feb 24 '20 at 11:31
  • 2
    thanks for your response, I have installed it by 3rd party installation, pgAdmin3 package is availabe in 19.10 but not pgAdmin4. – Sarthak Kumar Feb 25 '20 at 03:51
  • As @Punnerud mentions in another ticket, for Ubuntu 18.04 you will have to sign the repo when adding it. – moojen Mar 20 '20 at 09:29
  • I am using ubuntu 18.04 LTS.The key which you mention helps me : "sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -" not the complete one which i found in search with the problem. Many thanks – Noha Salah Oct 06 '20 at 20:39
  • I have modified my answer to allow for Ubuntu 16.04 (Xenial), Ubuntu 18.04 (Bionic), Ubuntu 19.10 (Eoan), Ubuntu 20.04 (Focal), Debian 9 (Stretch) and Debian 10 (Buster) installations. – Promise Preston Oct 07 '20 at 06:41
  • E: The repository 'https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/n/a pgadmin4 Release' does not have a Release file. this is what i am getting among other things on the second step. and the issue is still unsolved when i do apt install. I am trying to install this on parrot os(Debian 10) – Suraj Ingle Jul 19 '21 at 12:58
  • currently not working with Linux Mint 20 – x-magix Apr 13 '22 at 08:39
45

In my case, the following is working:

1st step:

curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add

Create the repository configuration file. In the above answer, the command mentioned below is now too old and the page returns 404, so the packages will not be downloaded successfully.

sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

2nd step:

The updated and working command is:

sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal/ pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

3rd step:

sudo apt install pgadmin4
karel
  • 5,489
  • 46
  • 45
  • 50
Basharat Ali
  • 1,099
  • 9
  • 11
7

For Ubuntu 18.04 you have to add the Postgresql repository and key to apt:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
 sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

After this you have to run

sudo apt update

Then you can install, ex. with "sudo apt install pgadmin4 pgadmin4-apache2 -y"

Punnerud
  • 7,195
  • 2
  • 54
  • 44
3

Run these Command bellow,

  1. sudo apt install curl
  2. curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
  3. sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
  4. sudo apt install pgadmin4

You can also check here.

Rubel
  • 1,255
  • 14
  • 18
1

This has worked for me

sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install pgadmin4 pgadmin4-apache2
Bala vamsi
  • 222
  • 1
  • 9
1
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

sudo apt install wget ca-certificates

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add

sudo apt update

sudo apt install pgadmin4

try this, I found it on : https://o7planning.org/11353/install-pgadmin-on-ubuntu#a6605357

and it worked, despite people saying there is no support for 20.04 (focal)

betelgeuse
  • 1,136
  • 3
  • 13
  • 25
0

The issue arises because the repository for pgadmin has not been added to your local machine. To solve the issue, do the following below;

Open your terminal and enter the command below

sudo nano /etc/apt/sources.list.d/pgdg.list

When nano editor opens up, copy and paste the line below into it

deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main

then copy and paste this thing

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

After that copy and paste this thing

sudo apt-get update && sudo apt-get install pgadmin4

Congratulations your job is done

Owen Kelvin
  • 14,054
  • 10
  • 41
  • 74
Dtheekshana
  • 82
  • 1
  • 10
0

Import the repository key from https://www.postgresql.org/media/keys/ACCC4CF8.asc

curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null

Create /etc/apt/sources.list.d/pgdg.list.

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Finally, update the package lists, and start installing packages:

sudo apt update

Provide the web interface accessible in a web browser:

sudo apt install pgadmin4-web

Provide desktop application for Ubuntu system, which required Ubuntu Desktop system:

sudo apt install pgadmin4-desktop

Install both, web and desktop:

sudo apt install pgadmin4

References: https://wiki.postgresql.org/wiki/Apt

vvvvv
  • 25,404
  • 19
  • 49
  • 81
tio_hecro
  • 127
  • 1
  • 5