Skip to content

pgAdmin 4

Lucian Cumpata edited this page Jul 22, 2019 · 9 revisions
  • How to connect to a postgresql database in linux through pgAdmin 4?

We assume that pgAdmin is installed on a Windows 10 host and postgresql db on a linux/ubuntu VM.

We also assume that the postgresql is installed with default settings.

In vagrant file I configured an IP adress for the VM:

config.vm.network :private_network, ip: "192.168.68.8"

and also forwarder port 5432:

config.vm.network :forwarded_port, guest:5432, host:5432

We'll reach the VM on 192.168.68.8

Edit the pg_hba.conf file located in /etc/postgresql/9.5/main directory

and add the following line under the " # Database administrative login by UNIX domain socket"

host all all 192.168.68.8/24 md5

Then we'll edit the postgresql.conf file located in /etc/postgresql/9.5/main directory

and change the following line under the "# - Connection Settings -" to listen_adresses = '*'

Don't forget to delete the '#' at the beginning if it exists!

After the file changes, you must restart postgresql by typing $ sudo service postgresql restart

Now launch pgAdmin 4 from your host machine (eg. Windows 10). It will open in a browser. Click on Add New Server

Type the name, doesn't matter. Then in Connection tab, enter the VM IP address defined earlier: 192.168.68.8 Port: 5432 (it's the default one). Leave the username and password (if you didn't add a password) and click save. It should automatically connect to the database.

Clone this wiki locally