title: Connect to existing instance of Postgresql from WSL 2
body: <p>I'm running Ubuntu WSL 2 on Windows 10. Before I installed WSL I already had Postgresql installed on my Windows 10. I wanted to connect to the database from WSL but so far it fails.</p>
  <p>When running:</p>
  <pre><code>psql
  </code></pre>
  <p>I get:</p>
  <pre><code>psql: error: could not connect to server: Connection refused
      Is the server running on host &quot;127.0.0.1&quot; and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  <p>When running:</p>
  <pre><code>psql -h 127.0.0.1 -p 5432 -U postgres
  </code></pre>
  <p>I get:</p>
  <pre><code>psql: error: could not connect to server: Connection refused
      Is the server running on host &quot;127.0.0.1&quot; and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  <p>And WSL clearly doesn't see the database. When running this:</p>
  <pre><code>sudo service postgresql start
  </code></pre>
  <p>It returns:</p>
  <pre><code>postgresql: unrecognized service
  </code></pre>
  <p>I know that one solution is to install the database in WSL but wanted to try to connect to existing instance first.</p>