1

How to connect to specific postgres version through psql when both (9.0 and 9.2) are on the same port? It's on RedHat 4.1.2.

1
  • 1
    In TCP/IP only one application can bind to a port at any one time, so you probably don't have two versions of an application running on the same port. Commented Jun 9, 2014 at 11:56

1 Answer 1

2

You can run two versions of PostgreSQL on the same port by having them bind to different IP addresses.

Assign multiple IP addresses to a network interface, or add an extra network interface. Say 10.1.1.2 and 10.1.1.3.

In your 9.1 install's postgresql.conf set your listen_addresses to one of the addresses; say 10.1.1.2. In the 9.3 install's postgresql.conf set listen_addresses to bind to 10.1.1.3. Restart both servers.

You might want to put 127.0.0.1 in the 9.3 server's listen_addresses so it binds to the local loopback address too. (Note that you can alias the loopback to add more IPs for the local host if you need to, e.g. 127.0.0.2).

If using separate IPs is not going to work for you, your only other option is to use a container that provides virtually isolated network stacks (like LXC), or use full virtualisation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.