Skip to main content
2 of 2
Minor formatting oversight now fixed. SPELLING ERROR in the TITLE!? Oops! Fixed!
Richard T
  • 219
  • 2
  • 6

postgres: could not access directory "C:/opt/PostgreSql/14/data": Permission denied

Importantly: This is on Windows 10 and Postgres 14 (for newbies, Postgres is also known as PostgreSQL), with Cygwin providing the CLI.

On a fully functional, up and running, and apparently perfectly happy installation, when trying to reconfigure to turn on ssl support in order to permit JDBC connections (as the new releases don't support the older driver methods), after providing server.crt and server.key, I made a few changes to postgresql.conf (which defaults to ssl params commented out) and a reload didn't work.

The server, still running as I only did a reload (pg_ctl reload), reported in the log (fluff not included):

2022-07-17 19:45:57.907 PDT [8980] LOG:  could not access private key file "server.key": Permission denied

So, at that moment, thinking I was the owner of it all, I restarted the server (again using pg_ctl). The shutdown went fine, but trying a restart turned out to be a mistake, apparently! From pg_ctl:

$ pg_ctl.exe start
waiting for server to start....postgres: could not access directory "C:/opt/Post
greSql/14/data": Permission denied
 stopped waiting
pg_ctl: could not start server
Examine the log output.

Curious! SO, of course, I checked permissions. NOPE, I was not the owner of the directory (IE installation - this is Windows!) so, I performed chown <owner> on the two server files and then tried.

With still no joy, I remembered the group permissions and, following the official Postgres documentation, ran chmod og-rwx server.key but that didn't work either! Arg!

Now, on attempting to restart NOTHING goes in the log and the user running pg_ctl gets this:

$ pg_ctl.exe start
waiting for server to start....postgres: could not access directory "C:/opt/Post
greSql/14/data": Permission denied
 stopped waiting
pg_ctl: could not start server
Examine the log output.

SO, I tried turning off ssl inside the postgresql.conf file... And STILL NO JOY! -slap-forehead-

My next step? I tried restarting the box - this IS Windows, after all! But 'nix and Postgres don't require such actions?! Frankly, I don't see what good backing out the SSL files does with the config turned off... And, I guess to NOT my surprise, Postgres did NOT come back following reboot! (Previously it has.)

And that's why I'm asking for help figuring out why this darned thing won't come up.

Richard T
  • 219
  • 2
  • 6