While installing PostgreSQL, I changed the port number in postgresql.conf file from 5432 to 5430, but the server is still listening to the old port (5432). How do I change it?
I opened the .conf file using nano, made the change to the port value, saved the file and restarted the terminal. I also restarted the postgreSQL server by stopping and starting it again, but the problem persists.
3
Answers
While creating the database, I wanted the server to listen to the server using port 5430. An alternate way to do this was to specify the port in the command instead of what's written in the file, such as running the following command:
pg_ctl start -D /path/to/data -o "-p 5430"
by doing so, the port number is changed.
After changing the port in the
postgresql.conf
file trysudo service postgresql restart
to restart the server, this way you won’t need the flag every time you usepg_ctl start
please verify if theres no multiple postgresql.conf files on your system and the server is using a different file than the one you modified. Run the following command to see the PATH of the configuration file:
So modify the port setting in this file and then restart the PostgreSQL server.