3

I am trying to view databases with pgAdmin. After starting pgAdmin and successfully entering my "master password". I get the following error while trying to open up the only instance, in this case: "PostgeSQL 12".

I am getting this pgAdmin error:

could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? 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?

Picture of: Connection refused error picture of: Connection refused error

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.

I did try right-clicking "PostgreSQL 12" and clearing the password but that did not resolve the issue.

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.

I am running the following: MacOS High Sierra 10.13.6 PostgreSQL 12 pgAdmin 4

UDATE 1: I found something: I think this is the installation full path: /Library/PostgreSQL/12/bin

I ran from bin: ./pg_ctl --help 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?

UPDATE 2: I ran ./pg_ctl start and got: "pg_ctl: no database directory specified and environment variable PGDATA unset"

UPDATE 3: I ran ./pg_ctl start -D /Library/PostgreSQL/12/data and got: "pg_ctl: could not open PID file "/Library/PostgreSQL/12/data/postmaster.pid": Permission denied"

Picture of: Directory picture of: Directory

UPDATE 4: ran from the bin folder found at /Library/PostgreSQL/12/bin I ran: sudo -u postgres ./pg_ctl start -D /Library/PostgreSQL/12/data and after inputing password:

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 "::", port 5432
2020-04-22 15:57:51.766 CDT [5255] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-04-22 15:57:51.768 CDT [5255] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
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 "log".
 stopped waiting
pg_ctl: could not start server

So, to answer some questions, I could not start the server; hence, the error I am getting in pgAdmin.

Raghav Garg
  • 3,601
  • 2
  • 23
  • 32
user13375649
  • 33
  • 1
  • 1
  • 5
  • Similar error here: (https://youtu.be/Q32iqfckSNw?t=293) However, this person is using Windows. On Mac, this command is not found using standard shell. Maybe the psql shell that came with pgAdmin is needed on Mac? – user13375649 Apr 21 '20 at 22:42
  • 1. Do check the postgresql 12 service is start 2. First try to connect with postgresql using psql from the postgresql installdir/bin – Amjad Shahzad Apr 22 '20 at 10:29
  • If you can't reach the database server in the first place, then it can't matter if your password is correct or not. Did you start the database server? Did the start succeed? – jjanes Apr 22 '20 at 12:45
  • @jjanes Please see update 2. How would I start the server? Thanks – user13375649 Apr 22 '20 at 19:26
  • Does the server automatically start upon boot? You must have had it running at some point, do you remember how you did it then? When you "restored from a backup", what is it you did? – jjanes Apr 22 '20 at 19:41
  • @jjanes Before I restored from backup, it did start automatically. Please see this [stackoverflow](https://stackoverflow.com/questions/7975556/how-to-start-postgresql-server-on-mac-os-x) and see the heading "If your computer was abruptly restarted". I'm thinking that is me since I restored; I am thinking about deleting the postmaster.pid. What do you think? – user13375649 Apr 22 '20 at 19:56

1 Answers1

1

If you are on windows, You need to start the Postgres in the task manager services section. That way It would connect automatically and ensure there is no firewall connection block on your port 5432. I tried it, and it worked.