DEV Community

Marco Aurélio Silva de Souza Júnior
Marco Aurélio Silva de Souza Júnior

Posted on

Setting Up pgAdmin 4 on Windows with PostgreSQL on WSL

In this blog post, we'll walk through the process of setting up pgAdmin 4, installed natively on Windows, to work with a PostgreSQL server running on Windows Subsystem for Linux (WSL). This guide assumes you have already installed PostgreSQL on WSL and pgAdmin 4 on your Windows system.

Step 1: Start the PostgreSQL Server on WSL

First, you need to start your PostgreSQL server on WSL. Use the pg_ctl command followed by -D and the directory of your database to start the server. The command should look something like this:

pg_ctl -D <your database directory> start
Enter fullscreen mode Exit fullscreen mode

Upon running this command, you should see an output similar to the following:

waiting for server to start....2023-07-13 12:08:01.660 -03 [4659] LOG:  starting PostgreSQL 16beta1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.1.1 20230429, 64-bit
2023-07-13 12:08:01.662 -03 [4659] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-07-13 12:08:01.676 -03 [4659] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2023-07-13 12:08:01.707 -03 [4662] LOG:  database system was shut down at 2023-06-30 17:18:29 -03
2023-07-13 12:08:01.738 -03 [4659] LOG:  database system is ready to accept connections
Enter fullscreen mode Exit fullscreen mode

Take note of the IPv4 address and port number where the server is listening. In this case, it's "127.0.0.1" and port "5432".

Step 2: Add a New Server on pgAdmin

Next, open pgAdmin and add a new server. In the "Connection" tab, enter the IPv4 address and port number you noted in the previous step into the "Host name/address" and "Port" fields, respectively.

Step 3: Specify the Maintenance Database

The "Maintenance database" field should be filled with the name of your PostgreSQL database. If you're unsure of your database name, you can list all available databases by running the psql --list command on WSL.

Step 4: Enter Your Username and Password

The "Username" and "Password" fields should be filled with your PostgreSQL username and password, respectively. This is the same username and password you use to connect to PostgreSQL on WSL.

Step 5: Name Your Connection

Finally, give your connection a meaningful name in the "Name" field under the "General" tab. This will help you identify this connection in the future.

Once you've filled out all the necessary fields, save your new server configuration. You should now be able to connect to your PostgreSQL server on WSL using pgAdmin 4 on Windows.


I make these posts in order to guide people into the development of a new technology. If you find anything incorrect, I urge you to comment below so I can fix it. Thanks!


Check Apache AGE: https://age.apache.org/.

Overview — Apache AGE master documentation: https://age.apache.org/age-manual/master/intro/overview.html.

GitHub - apache/age: https://github.com/apache/age

Top comments (0)