4

I have a particular issue with PostgreSQL 10:

Postgres creates backend processes for each connection on different ports. The problem is that some of our apps also use many ports and sometimes they collapse with Postgres resulting in a port binding error.

One workaround is to first start apps and then the Postgres service, but I'm looking for a cleaner solution.

Do you know if there's a way to specify a port range used by Postgres for backend processes? I have not found something built-in so far.

4
  • 1
    You will need to provide more details on "some of our apps also use many ports and sometimes they collapse with Postgres" because PostgreSQL basically listens on only one port, which is then multiplexed for backends. What are exactly the error messages you get? – Patrick Mevzek Jul 9 '19 at 16:38
  • the error is port binding error: address already in use. When I kill the postgresql child process running in that port, then the app works ok. It seems that postgresql randomly occupies ports for child processes. – jchiavaro Jul 9 '19 at 17:04
  • 1
    "It seems that postgresql randomly occupies ports for child processes. " I seriously doubt so, and you did not provide actual details. See postgresql.org/docs/current/connect-estab.html "As we do not know ahead of time how many connections will be made, we have to use a master process that spawns a new server process every time a connection is requested. This master process is called postgres and listens at a specified TCP/IP port for incoming connections." Your application might be reusing the client port IDs, those connecting to PostgreSQL. – Patrick Mevzek Jul 9 '19 at 19:40
  • Thanks @PatrickMevzek you're righ.t It seems I got the wrong logs and output and we messed up PIDs with port numbers. It's not realistic that postgresql can randomly open ports without control. Sorry for the confusion. – jchiavaro Jul 9 '19 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.