title: pgAdmin: could not connect to server: Connection refused
body: <p>I am trying to view databases with pgAdmin.  After starting pgAdmin and successfully entering my &quot;master password&quot;.  I get the following error while trying to open up the only instance, in this case: &quot;PostgeSQL 12&quot;.</p>
  <p>I am getting this pgAdmin error:</p>
  <blockquote>
  <p>could not connect to server: Connection refused Is the server running on host &quot;localhost&quot; (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host &quot;localhost&quot; (127.0.0.1) and accepting TCP/IP connections on port 5432?</p>
  </blockquote>
  <p>Picture of: Connection refused error
  <a href="https://i.stack.imgur.com/gFv2Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gFv2Y.png" alt="picture of: Connection refused error" /></a></p>
  <p>After entering the correct and only password I have used for 4 or so different programs: I get the same pop-up error.  None of the programs access the database any longer.</p>
  <p>I did try right-clicking &quot;PostgreSQL 12&quot; and clearing the password but that did not resolve the issue.</p>
  <p>I will say that I recently restored from a backup because I did a hardware upgrade where I swapped out a HDD to a SSD.</p>
  <p>I am running the following:
  MacOS High Sierra 10.13.6
  PostgreSQL 12
  pgAdmin 4</p>
  <p><strong>UDATE 1:</strong>
  I found something: I think this is the installation full path: /Library/PostgreSQL/12/bin</p>
  <p>I ran from bin:
  <code>./pg_ctl --help</code>
  and got the full help menu options.  Would I now have to run status, start, or stop on the correct server?  Which server or file might that be?  Is it data, which seems to be locked?</p>
  <p><strong>UPDATE 2:</strong>
  I ran <code>./pg_ctl start</code>
  and got: &quot;pg_ctl: no database directory specified and environment variable PGDATA unset&quot;</p>
  <p><strong>UPDATE 3:</strong>
  I ran <code>./pg_ctl start -D /Library/PostgreSQL/12/data</code>
  and got: &quot;pg_ctl: could not open PID file &quot;/Library/PostgreSQL/12/data/postmaster.pid&quot;: Permission denied&quot;</p>
  <p>Picture of: Directory
  <a href="https://i.stack.imgur.com/UZNKg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UZNKg.png" alt="picture of: Directory" /></a></p>
  <p><strong>UPDATE 4:</strong>
  ran from the bin folder found at /Library/PostgreSQL/12/bin I ran:
  <code>sudo -u postgres ./pg_ctl start -D /Library/PostgreSQL/12/data</code>
  and after inputing password:</p>
  <pre><code>waiting for server to start....2020-04-22 15:57:51.766 CDT [5255] LOG:  starting PostgreSQL 12.2 on x86_64-apple-darwin, compiled by Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn), 64-bit
  2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv6 address &quot;::&quot;, port 5432
  2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv4 address &quot;0.0.0.0&quot;, port 5432
  2020-04-22 15:57:51.768 CDT [5255] LOG:  listening on Unix socket &quot;/tmp/.s.PGSQL.5432&quot;
  2020-04-22 15:57:51.782 CDT [5255] LOG:  redirecting log output to logging collector process
  2020-04-22 15:57:51.782 CDT [5255] HINT:  Future log output will appear in directory &quot;log&quot;.
   stopped waiting
  pg_ctl: could not start server
  </code></pre>
  <p>So, to answer some questions, I could not start the server; hence, the error I am getting in pgAdmin.</p>