skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. After changing the port in the postgresql.conf file try sudo service postgresql restart to restart the server, this way you won’t need the flag every time you use pg_ctl start

    Login or Signup to reply.
  3. 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:

    psql -U postgres -c "SHOW config_file"
    

    So modify the port setting in this file and then restart the PostgreSQL server.

    sudo service postgresql restart
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search