This post talks about using pg_ctl to register PostgreSQL as a service on Windows. In my experience many big PostgreSQL instances are on Linux / UNIX these days. However, recently we have seen quite a number of Windows systems running PostgreSQL for a bigger production system. There are still rarely really large databases (XX TB) on Windows. However, Windows might very well catch up a bit in the future.

On Linux there are ready to use packages, which make it very easy to deploy more than just one instance on a single node.

On Windows the story is a bit different. I have seen many people, who had a hard time registering services. To all of those out there suffering in silence there is a hopefully vital piece of information…

Nice and easy: pg_ctl

If you happen to run Windows, pg_ctl provides a nice way to register a service:


pg_ctl register [-N servicename] [-U username] [-P password]
       [-D datadir] [-S a[uto] | d[emand] ] [-w] [-t seconds] [-s] [-o options]

Using “pg_ctl register” is a lot easier than to fiddle around with Windows command line interfaces in general. It allows people to quickly register services in a nice and clean way.

Read on to find out more about PostgreSQL and Windows on Pavlo’s blog detailling install and setup for PostgreSQL on WSL2 for Windows.