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?

2
  • 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. Commented Nov 4, 2012 at 0:54
  • See also: github.com/mattt/PostgresApp/issues/56 Commented Nov 4, 2012 at 0:54

5 Answers 5

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)

Sign up to request clarification or add additional context in comments.

3 Comments

Changing postgresql.conf has no effect on this configuration.
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 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.
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.

Comments

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.

1 Comment

I can confirm this works on El Capitan with PG 9.5. vim ~/Library/Application\ Support/Postgres/var-9.5/postgresql.conf
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.)

3 Comments

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 (github.com/mattt/PostgresApp/issues/56) :( so i've installed official version of postgres, it works
Mike, you could be maybe talking about the stackbuilder version perhaps? I think we are all referencing the standard Postgresql.app.
@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.
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).

5 Comments

Your instructions worked for me. However, three digit port numbers such as 420 didn't work for me. Four digit port numbers worked though.
Are you able to change the port number to a three digit one, such as 420?
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 -> unix.stackexchange.com/questions/10735/… but know this is a networking question rather than a Postgres on Mac question.
I was able to change it to 420 using Docker Compose: stackoverflow.com/questions/37775702/….
Good to hear you found a workaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.