PostgreSQL for Windows

Run PostgreSQL as a Windows Service

The Windows installer registers a service automatically. Tune startup type, service account, and recovery options for a reliable PostgreSQL on Windows 10/11.

The service name typically includes the version (e.g., a “postgresql-x64-XX” pattern).

Quick checklist

  • Service installed and visible in Services (services.msc).
  • Startup type set to Automatic (Delayed Start).
  • Service runs under a least‑privilege account.
  • Recovery options set to restart on failure.

Configure via Services (services.msc)

  1. Open the Windows Services console and locate the PostgreSQL service.
  2. Open Properties → General and set Startup type to Automatic (Delayed Start).
  3. In Log On, select a dedicated account with minimal privileges, and provide credentials if needed.
  4. In Recovery, set First failure and Second failure to Restart the Service. Configure the restart delay.
  5. Apply changes, then Start or Restart the service to validate.

Manual registration (overview)

If you installed PostgreSQL from binaries or need a custom setup, you can register it as a service using supported tools. Ensure the service account has access to the data directory and the executable. Prefer the official installer for simplicity.

Logs and rotation

Default location

By default, server logs reside inside the data directory. Check your configuration to confirm the exact path.

Rotation basics

Use built‑in logging settings to rotate logs regularly and avoid large files. Adjust retention to your policy.

Permissions

Ensure the service account can write to the log directory and the data folder without excessive privileges.

Firewall and remote access

To allow remote connections, create an inbound rule for the PostgreSQL port (default 5432) in Windows Defender Firewall, and configure client access in your server settings. Limit exposure to trusted networks.

Troubleshooting — quick answers

Service won’t start

Check data directory permissions and verify that configuration paths are correct. Review the latest server logs for details.

Starts, then stops

Inspect logs for fatal errors. Ensure the port is free and the service account can access required files.

Wrong account

Switch to a dedicated least‑privilege account in the service Log On tab and restart the service.

Related guides

Disclaimer: This is an unofficial resource. PostgreSQL is a registered trademark of the PostgreSQL Community Association of Canada. Links may include affiliate tracking.