7

I just installed Postgres.app on my Mac, and I need to make some specific configuration to server. For example I want to use different port, not 5432.

I found that it have postgresql.conf at ~/Library/Application\ Support/Postgres/var/postgresql.conf, but even if I change value of port = to something other, it listen on 5432 after server restart.

Seems that this postgresql.conf isn't used by Postgress.app. Where it stores server configuration files?

titanofold
  • 2,852
  • 1
  • 15
  • 21
Igor Artamonov
  • 35,450
  • 10
  • 82
  • 113
  • 3
    To make sure you're editing the correct `postgresql.conf`, run `SHOW config_file;` while Postgres.app is running. If you are editing the right one: is it changed back when you start Postgres.app? If so, the app probably expects you to change the port via the preferences. If it isn't changed back but is just ignored, maybe the app is overriding the port on the postgres command line; again, check for preferences in Postgres.app. – Craig Ringer Nov 04 '12 at 00:54
  • See also: https://github.com/mattt/PostgresApp/issues/56 – Craig Ringer Nov 04 '12 at 00:54

5 Answers5

11

The postgresql.conf-file at ~/Library/Application\ Support/Postgres/var/ is used by Postgres.app. The only problem: if you change the port in that file, that change will not be reflected in the menu-bar. So the elephant over there will still say "Running on Port 5432", although postgres might be running on, for example, port 5433. (Mac OS X 10.8.2, Server.app 2.2, Postgres.app 9.2.2.0)

Paul
  • 134
  • 1
  • 4
  • 1
    Changing postgresql.conf has no effect on this configuration. – Thomas Farvour Nov 18 '13 at 17:25
  • 3
    This answer is incorrect. Even though `SHOW config_file` shows that this config file is used, the port number is overwritten by the command line setting. – mdrozdziel Jan 30 '14 at 17:10
  • @mdrozdziel I also struggled a bit with port changing, but then noticed that row `port = xxx` started with `#`, i.e. was commented by default. After I removed `#` and restarted Postgress.app, the port changed. – Alexander Kachkaev Oct 03 '14 at 14:43
2

I can see the output from ps aux |grep post /Applications/Postgres.app/Contents/MacOS/bin/postgres -D /Users/chenc26/Library/Application Support/Postgres/var -p5432 So I think there must be some config in this app to specify the CLI parameter which ignore the value from config file.

kyrre
  • 327
  • 3
  • 9
2

I'm running a Mavericks 10.9.3 and opening Postgres app v9.3 config via nano ~/Library/Application\ Support/Postgres/var-9.3/postgresql.conf and uncommenting the port = 5432 line, then changing it to, say, 5433 did the trick for me. (Restarting the app was required, as the config file mentions). Afterwards the app correctly displays that it is running on port 5433.

Epigene
  • 3,634
  • 1
  • 26
  • 31
0

If correctly changing the content of postgresql.conf, then restarting the PostgreSQL server doesn't change the port it's listening on, you're almost certainly editing the wrong postgresql.conf.

On other platforms, PostgreSQL puts a copy of its default version of postgresql.conf in the data directory. So you're liable to find at least two copies of all the configuration files somewhere on your computer--usually one in the directory where the distribution or source was downloaded or uncompressed, and one in the data directory. On your Mac, if you're using version 9.1, the data directory might be

/Library/PostgreSQL/9.1/data/

Check for a postgresql.conf there. If you find one, consider making a copy of it to replace the one you edited. (So the one you edited will again be an unedited version.)

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
  • No, there are no such dir (/Library/Postgre*). And 'find / -name postgres.conf' can find only one, that i've tryed to edit. Seems that it's bug at Postgres.app (https://github.com/mattt/PostgresApp/issues/56) :( so i've installed official version of postgres, it works – Igor Artamonov Nov 03 '12 at 23:03
  • Mike, you could be maybe talking about the stackbuilder version perhaps? I think we are all referencing the standard Postgresql.app. – Harlin Dec 21 '22 at 14:40
  • 1
    @Harlin: 10 years ago, but no, I was talking about the standard Postgresql app on Mac OS. Back then, I didn't know anything about stackbuilder. – Mike Sherrill 'Cat Recall' Dec 21 '22 at 19:22
0

In 2022, I can't just edit the server.conf file. It looks like instead, I've had to do this from the GUI to change the port which the command line parameters refer to:

... bin/postgres -D /Users/MyUser/Library/Application Support/Postgres/var-11 -p 6543

The way I was able to make the change was to:

  1. Open the Postgres elephant icon in the top bar.

  2. Select "Open Postgres"

  3. Stop the server.

  4. Click on server settings.

  5. Then, change the port in the simple input.

  6. After this, start the server and find that the port has changed.

This works for the Postgres.app (version 11 on my desktop).

Harlin
  • 1,059
  • 14
  • 18
  • Your instructions worked for me. However, three digit port numbers such as 420 didn't work for me. Four digit port numbers worked though. – lanadelrey Jan 05 '23 at 02:04
  • Are you able to change the port number to a three digit one, such as 420? – lanadelrey Jan 05 '23 at 02:07
  • Ports below 1024 are special privilege (this goes for any networked application). I would advise keeping your port for Postgres higher than 1024 so that it can be run by the postgres user. If you must do it, there are workarounds -> https://unix.stackexchange.com/questions/10735/allowing-a-regular-user-to-listen-to-a-port-below-1024 but know this is a networking question rather than a Postgres on Mac question. – Harlin Jan 05 '23 at 13:02
  • 1
    I was able to change it to 420 using Docker Compose: https://stackoverflow.com/questions/37775702/changing-a-postgres-containers-server-port-in-docker-compose. – lanadelrey Jan 05 '23 at 19:40
  • Good to hear you found a workaround. – Harlin Jan 06 '23 at 02:04