Determining PostgreSQL's port
Solution 1
lsof and nmap are solutions, but they're not installed by default. What you want is netstat(8).
sudo netstat -plunt |grep postgres
Solution 2
The PostgreSQL utility pg_lsclusters shows information about the configuration and status of all clusters, including the port number.
$ pg_lsclusters
Version Cluster Port Status Owner Data directory Log file
8.4 main 5433 online postgres /var/lib/postgresql/8.4/main /var/log/postgresql/postgresql-8.4-main.log
This also has the advantage of not requiring 'sudo' privileges to run.
On Debian and Ubuntu systems, the pg_lsclusters command is provided by the package postgresql-common, which should be installed by default with the postgresql server.
Solution 3
If you want to do it from inside the database, just do "SHOW port". But that assumes you've been able to connect to it, at least locally...
Solution 4
I have machines with multiple postgres instances running -- and so I also have the issue of trying to match up the correct database with each port. I tend to do:
$ ps aux | grep postgres | grep -v 'postgres:'
And then, for each of instances returned look for the directory (-D
argument) and:
$ sudo grep port $DIR/postgresql.conf
Solution 5
If you are searching on the local machine, I would use the lsof command to check for the port postgresql is using
lsof -p <postgres_process_id>
Related videos on Youtube
Andreas
Updated on September 17, 2022Comments
-
Andreas over 1 year
I'm using iScroll 4 (cubiq.org/iscroll-4) in a JQTouch iPhone-application built with Phonegap/Cordova.
My problem is that the horizontal scrolling, although 'hScroll: true', is not enabled until I zoom my image in and out, which makes everything work fine (confirming that the iScroll works and the CSS of the wrapper/scroller are correct).
HTML:
<div id="wrapper"> <div id="scroller"></div> // Also tried with img-tag in div instead of as bg </div>
CSS:
#wrapper { position:absolute; top:45px; bottom:0; left:0; // 45px is header z-index:1; width:100%; // Also tried with window size (320) overflow:auto; // Also tried with scroll } #scroller { position:absolute; z-index:1; width: 1024px; // The size of my image height: 414px; // The height of my image background: url(img/test.png) no-repeat; padding: 0; }
JAVASCRIPT:
var myScroll; function loaded() { myScroll = new iScroll('wrapper', { hScrollbar: true, vScrollbar: true, hScroll: true, vScroll: true, zoom: true }); }
Changing the parameters of 'vScroll' and 'zoom' has the desired effects right away. Parameters related to horizontal scrolling does nothing until after zooming has fired it.
I tried refreshing the wrapper or scrolling to a coordinate after load, editing the loading order of my app, but nothing helps.
Thanks for your time, Andreas.
-
Lucas Wiman over 11 yearsDid you ever solve this question? I would be fascinated to know the answer, as I'm having a similar issue.
-
-
Michael Mior about 14 yearsYou may have to run this as root.
-
Andreas almost 12 yearsThanks for your reply. I didn't see anything about this in the iScroll documentation or demo. I'm not sure if it would work for me, as I decided to rebuild my app from scratch - but hopefully it might help others in this situation. Thanks again!
-
Andreas over 11 yearsI went back and tried this solution, and it did not help. Also edited my question to further explain my issue.
-
Andreas over 11 yearsI edited the question after your comment, but concerning the CSS, I have tried pretty much every solution I can think of - all with the same result. Thanks though.
-
voretaq7 over 11 yearsNote that
pg_lsclusters
is an Ubuntu-ism, and is not a standard Postgres command. It will work for this case, but is not a general-purpose solution... -
GrayedFox almost 6 yearsThere is no
g
flag anymore for thess
command. Try:ss -pa |grep postgresql
-
ptman almost 6 years@GrayedFox thanks for the update, but for me that gives the name of the port, not the number, so I think
ss -pan |grep postgres
is more suitable