27
votes

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.

6

6 Answers

92
votes

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)

That's all.

I hope this helps.

9
votes

for my case this is working. in above answer 2nd step is outdated because link not accessible. 1st step

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

Create the repository configuration file: in above answer this command mentioned but now its too old because this page returns the 404 and packages not 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 this command is updated and working now

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
7
votes

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"

1
votes

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
0
votes

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

0
votes

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.