0

We are trying to use port 5444 for our new PostgreSQL instance and we are not sure whether 5444 is used or unused.

Could you please help us to find the answers to the below questions.

  1. We want to find out all the used and unused ports report on PROD Linux servers (RHEL 7.2).

  2. Also find out the application port even the application was shutdown.

Is there any file on Linux servers which holds all the ports (or sockets) info for helping with the above query?

1
  • "We are trying to use port 5444" why? what is wrong with PostgreSQL default port? While in theory any port number is as good as any other port number, the default one has the nice property of... being the default one that is being recognized by all relevant tools without having to specify it. So without any good reason to change it, you will save yourself time and energy by just leaving it at that. Commented Sep 21, 2019 at 2:07

1 Answer 1

4

netstat -an | grep LISTEN | grep 5444 will show if there's a process listening on that port.

netstat -an | grep LISTEN will show you all ports with a process listening on them. You can then use lsof to see which processes are actually using a given port.

There's no such concept of "find out the application port even the application was shutdown", as anything can listen on any port (with certain restrictions if not running as root). The closest thing to this is the /etc/services file, which documents ports that are "well known"/assigned by IANA. Also see http://www.iana.org/assignments/port-numbers. But, as I said, there's nothing to stop anything from running on one of these ports.

To be honest, you should know what's running on a production box that you have root access to?

1
  • The "application" port PostgreSQL will use upon start is written in its configuration file, and defaults to 5432. Commented Sep 21, 2019 at 2:05

Your Answer

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

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