Search code examples
ruby-on-railspostgresqlwindows-10pgadminbash-on-windows

PgAdmin on Windows 10 with Postgres when installed via Bash on Ubuntu on Windows


I would like to install Rails 5/Postgres within Bash On Ubuntu On Windows and also be able to access Postgres database via PgAdmin for Windows.

Am quiet happy to install all my rails dependencies through Bash on Ubuntu on Windows, but I am aware that I can't run any standard GUI tools from Bash and was wondering if it is possible to install Rails and PostGres on the Linux Subsystem and then query my databases using the Windows version of PgAdmin

I had a look at this tutorial how-to-install-ruby-on-rails-on-windows-10-with-postgresql but it seems that he installs Postgres into windows rather then the Linux Subsystem.

I was wondering if this is the only way to go about getting all these tools working nicely together.

Basically I want my Windows installed PgAdmin to communicate to my Bash On Ubuntu On Windows Postgres DB


Solution

  • Edit: on step 5.2, use 127.0.0.1 instead of localhost if you get a timeout server error or something like that, thanks to Catriona response below.

    Here's what I did to connect Postgres DB installed in WSL Ubuntu from Windows pgAdmin.

    1. Launch Ubuntu in Windows.
    2. Start postgres in Ubuntu terminal: sudo service postgresql start
    3. Download the latest pgAdmin and install in Windows.
    4. Launch pgAdmin, a new tab in browser opens; click on Add New Server link.
    5. In the popup Create - Server window in the browser:
      1. General tab: I set Name to localhost
      2. Connection tab: I set Host name/address to localhost, set Password to postgres, which is the default, click on Save password?
      3. I save the setting, leaving the rest of the fields as is
    6. That's it, I can see the DB created in Postgres immediately.

    Browser screenshot on adding a server