I have Ubuntu in a Window (which I installed from Microsoft Store). In this Ubuntu, I have a Ruby web app in this Ubuntu which connects to Postgres in my Window (not Ubuntu). This is my database.yml
(/apps/appname/config/)
development:
adapter: postgresql
encoding: unicode
pool: 5
host: localhost
port: 5432
database: xxx
username: postgres
password:
All these I have setup accordingly. When I run rails server
, the web app starts and listening to localhost:3000. When I open the browser at localhost:3000, I get this error below:
> PG::ConnectionBad at /sign_in could not connect to server: Connection
> refused Is the server running on host "localhost" (127.0.0.1) and
> accepting TCP/IP connections on port 5432?
I have troubleshoot by running psql
and I can connect to the database at port 5432.
Server [localhost]:
Database [postgres]: xxx
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (10.15)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
How do I troubleshoot this further? I realize that I didn't run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
in Windows PowerShell in Window before I install Ubuntu. Could the issue due to this step which I miss out?