Specifying non-default port for Homebrew Postgres server

Viewed 189

I have installed Postgres using Homebrew on macOS. I can start a Postgres server which listens to the default port 5432 using the command brew services start postgres, but I want it to use a different port.

Using my Homebrew Postgres installation, how can I start a Postgres server which listens to another port?

1 Answers

If pg_ctl is installed (it should be - but you can check with which pg_ctl) you can use it to specify the port when starting your Postgres server:

pg_ctl -o "-p 5433" start

Documentation

Related