0

I have a PgAdmin server running on localhost and I'm trying to connect to it from another computer on the same network (they have the same IPv4 address).

I've gone through a lot of questions but all of them explain how to connect to a remote server, which I assume is running on an available host.

I've tried:

  • adding listen_addresses = '*' to postgresql.conf (on both computers)
  • adding host all all 0.0.0.0/0 md5 to pg_hba.conf (on both computers, replacing 0.0.0.0/0 with a variety of ip addresses)
  • some other things I saw in tutorials but don't remember

What I'm trying to understand is:

  • Is it possible to connect remotely to a server running on localhost?
  • If it is possible, which IP address does the remote computer need to connect?
half of a glazier
  • 1,864
  • 2
  • 15
  • 45
  • pgAdmin server or PostgreSQL server? Two computers in your network share the same IP address? What error message do you receive when connecting? – Julius Tuskenis Apr 28 '21 at 13:17
  • @JuliusTuskenis PgAdmin and Postgres - I'm not sure what the difference is? Isn't postgres used in pgadmin? The computers have different ip addresses but the same ipv4 addresses. Error message is `connection timed out` or something along those lines – half of a glazier Apr 28 '21 at 13:21
  • postgresql is database server and pgAdmin is db management tool, that is client of postgresql. On the other hand pgAdmin 4 is written as a web application that runs a web server on the host the pgAdmin4 is installed. So I wonder if you want to connect to postgresql server from another computer in your network, or pgAdmin4 application server. – Julius Tuskenis Apr 28 '21 at 18:04
  • I want to be able to access a database in pgAdmin from another computer, to do that do I have to connect to the postgresql server or pgadmin? – half of a glazier Apr 28 '21 at 20:19
  • To setup remotely accesible server https://community.perforce.com/s/article/250 (on computer 1). On computer 2 you don't have to have postgresql - just pgAdmin. https://www.pgadmin.org/docs/pgadmin4/development/server_dialog.html enter computer1 address into host, port number (default 5432) username and password. – Julius Tuskenis Apr 29 '21 at 07:00

2 Answers2

0

You need to resolve some basic questions first:

  • What is the IP of the computer where PG is running? e.g. 192.168.100.10
  • Which port is PG exposed on? e.g. 9999

After you collected the two above information you can go on the second computer where you have pgAmin and execute

telnet <host> <port>

substituting <host> and <port> with the info collected above. If telnet replies with

Trying ::1...
Connected to <host>.
Escape character is '^]'.

this should mean that the port is open and PG should be listening on that host:port. You found your connection string to PG!

Ftisiot
  • 1,808
  • 1
  • 7
  • 13
  • The url in the browser where PgAdmin is running is `http://127.0.0.1:54298/browser/`, which is localhost. Does this make a difference to using the actual IP address of the computer? (running telnet with all the hosts and ports I can think of still gives `connect failed`) – half of a glazier Apr 28 '21 at 13:27
  • `127.0.0.1` is the `localhost`... it's the INTERNAL address of the computer you're working on. you need to connect to another computer, so you need to find their extenal IP. Nice description of localhost is [here](https://stackoverflow.com/questions/6938039/localhost-vs-real-ip-address) – Ftisiot Apr 28 '21 at 13:38
0

I am just sharing my understanding here. Corrections are welcome.

pgAdmin can connect to one/more postgres servers via TCP over using JDBC like protocol. pgAdmin is just a stand-alone web-interface ( web adapter ).

So some web-server configuration/tuning should be needed in pgAdmin configuration to enable access from remote machines.