Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I run Postgresql 8.4 as a service on a CentOS 6.2 server.

I set port = 21444 and listen_addresses = '*' in /var/lib/pgsql/data/postgresql.conf

and I changed 5432 to 21444 in postmaster.opts and restarted postgres, but when I run netstat -lntp postgresql is still running on port 5432

tcp        0      0 0.0.0.0:5432                0.0.0.0:*                   LISTEN      20276/postmaster 

When I restart postgresql I get a writting error warning on /proc/self/oom_adj, but the service starts anyway.

I read that we could get this error when using virtualized servers, but I don't really know if this has inpact on postgresql listening port.

The correct pgsql config file is loaded in /var/lib/pgsql/data :

[root@srv02 ~]# ps -ef | grep postgres
root      1358 22140  0 09:42 pts/0    00:00:00 grep postgres
postgres  9519     1  0 Mar16 ?        00:00:01 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres  9573  9519  0 Mar16 ?        00:00:00 postgres: logger process                          
postgres  9575  9519  0 Mar16 ?        00:00:05 postgres: writer process                          
postgres  9576  9519  0 Mar16 ?        00:00:03 postgres: wal writer process                      
postgres  9577  9519  0 Mar16 ?        00:00:01 postgres: autovacuum launcher process             
postgres  9578  9519  0 Mar16 ?        00:00:01 postgres: stats collector process             

any thought ?

thanks, Jerec

share|improve this question
    
The line of netstat output you pasted above shows a UNIX socket listener, not a TCP listener. You should use netstat -lntp to only show TCP listeners. –  ThatGraemeGuy Mar 15 '12 at 12:33
    
sorry, I replaced it –  Jerec TheSith Mar 15 '12 at 13:17
add comment

3 Answers

Are you restarting it using a restart action, or are you stopping the service and then starting it again?

I have Ubuntu, but I managed to get the same behaviour as you by restarting, but when I stopped and then started postgresql, it listened on the new port. So try to stop it and then start it, and see if it starts listening on the new port.

share|improve this answer
    
I tried this too, but I'm getting the same warning when stopping/starting or restarting the service, and pgAdmin3 can't connect on port 5432 –  Jerec TheSith Mar 16 '12 at 10:15
    
Are you sure you're editing the correct config file? Run ps -ef | grep postgres and you should see a line that includes the config file path as an option. For example mine looks like this: config_file=/etc/postgresql/8.4/main/postgresql.conf –  ThatGraemeGuy Mar 18 '12 at 19:22
    
Thanks for your help, ps show that the correct pgsql process is started, even though the config file is not displayed in this output –  Jerec TheSith Mar 19 '12 at 8:46
add comment

I have same problem when trying to set port number in postgresql.conf, as many instructions indicated. Your ps -ef reads:

/usr/bin/postmaster -p 5432

this line tells it starts at 5432.

It is run by the service start script, in my case (CentOS6.3 + postgresql-9.1) it's here:

/etc/rc.d/init.d/postgresql-9.1

There is a line read:

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

So All I did is go to /etc/sysconfig/pgsql, create a new file postgresql-9.1, add one line there: PGPORT=8100. In above case, you should add PGDATA=. Note, the filename should be the same as your service name, if you don't know, use

chkconfig --list | grep post* 

to find out.

Then restart the server by:

sudo service postgresql-9.1 restart.
share|improve this answer
    
thank you very much I'll try this this fternoon. is this a bug that should be reported to postgresql ? –  Jerec TheSith Feb 5 '13 at 9:37
    
@JerecTheSith, it could be a bug, or they are encourage user to set PGPORT that way (maybe other ways in other linux distro) –  simonxy Feb 5 '13 at 20:18
add comment

in /etc/init.d/postgresql-9.3 find PGPORT = 5432 and change it to Your Desired Port Number then restart. It solved my problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.