I'm trying to connect remotely on pgAdmin to a database hosted on a Windows 10 PC on another network from my personal PC.
Steps taken:
Changed listen_addresses = 'localhost' to listen_addresses = '*' in postgresql.conf file.
Added line host all all 0.0.0.0/0 to pg_hba.conf file.
Restarted postgresql service.
Opened port in firewall for port 5432
Tried to connect to database via pgAdmin on my PC by entering:
Host name: IPv4 address of machine database is hosted on.
Port:5432, Database: postgres, user: postgres, password: password
I can't see any error except a connection timed out error every time, but I don't know why. I've increased the connection timeout duration but still no connection. PostgreSQL service is running and I can connect to the database via pgAdmin just fine on the hosting PC.
Can anyone let me know if I'm skipping a step or anything else I need to add to the config files?
Thanks
Related
I have a postgres database called salephone_test with 3 tables (smartphones, listings, phone_listings) on my windows pc which I want to replicate to at least one ubuntu droplet on digitalocean. I attempted the following setup to replicate the smartphones table:
On my local machine (pc) in postgresql.conf I set the listen_addresses = '*' and wal_level = logical
in pg_hba.conf, I added the following lines
host salephone_test rep 0.0.0.0/0 md5
host salephone_test all 104.248.54.230/0 md5
host all all 0.0.0.0/0 md5
host all all 0.0.0.0/0 md5
where 104.248.54.230 is the IP of my digitalocean droplet
I also set up a replication user and publication by the following commands
CREATE ROLE rep REPLICATION LOGIN PASSWORD 'fakepass';
GRANT SELECT on smartphones to rep;
CREATE PUBLICATION test_phones FOR TABLE smartphones;
on my remote droplet, after installing postgres on the ubuntu, I created a database called salephone with a table called smartphones
in psql, I then used the following command to subscribe for logical replication
// 50.71.125.50 is my pc ip according to google
CREATE SUBSCRIPTION phone_sub CONNECTION 'dbname = salephone_test host = 50.71.125.50 user = rep password = fakepass port = 5432' PUBLICATION test_phones;
after a minute of waiting, I received the following
ERROR: could not connect to the publisher: connection to server at "50.71.125.50", port 5432 failed: Connection timed out
Is the server running on that host and accepting TCP/IP connections?
Note: i tried restarting postgres on my pc multiple times already via services.msc
Your home modem/router is surely blocking the connection. You will need to configure it to accept the connection and do 'port forwarding' to your pc. How you do that (or if it is even possible) would depend on the make and model of the router.
Also, your pg_hba doesn't make much sense. The reason to have a more specific entry above a more general entry is to give it a different auth method (or configuration). Since all your entries have the same method, you might as well just have the last line and not have the preceding 3.
I am trying to connect to a database from a remote computer. According to the guides, I configured the files in the pg_hba file by setting 0.0.0.0/0 for IPv4, similarly for IPv6 and for the file in PostgreSQL listen_addresses = '*'. The firewall allowed any connections to port 5432. I use pgAdmin try 4 and in the server settings - the host/addresses for some reason remained on localhost, every time I try to insert my network address there (in X.X.X.0 does not work), a long download occurs, after which the password for the Postgres database user is requested and the error "connecting to the server on "H.H.H.0", port 5432 failed...". At the same time, everything works on localhost. What am I doing wrong?
I am trying to connect to a VM ubuntu from my local computer. On the VM I have created a postgresql database. Then I followed all steps that I could find on several tutorial when it comes to allow access for remote connexion to the db:
add host all all 0.0.0.0/0 trust to the pg_hba.conf file
add listen_addresses = '*' to the postgresql.conf file
remove the firewall by executing sudo ufw allow 5432/tcp
restart postresql by executing sudo systemctl restart postgresql
By using the command psql and then \c gives You are now connected to database "postgres" as user "postgres".
I then create a password by executing ALTER USER postgres WITH PASSWORD 'password';
Then I use postico to connect locally. I want to connect with this same default superuser postgres for testing. I use the VM ip address as host, db name is postgres user postgres, password is password and port 5432 as mentioned above.
After trying to connect for a while with the message opening connection to server, the result is:
could not connect to server: Operation timed out
Is the server running on host "***.**.**.***" and accepting
TCP/IP connections on port 5432?
Any help please? I did all steps I could find on many tutorials but still failing to connect.
I am pretty new to everything that is database management, remote connection etc... And I need this for a university project.
I have a local postgreSQL database on my Windows computer, which I access through localhost. What I want to do now is connect to this database using my laptop (which is in the same WLAN, don't know if that helps).
I changed the file pg_hba.conf, and added host all all 0.0.0.0/0 md5 and host all all ::0/0 md5. Also in the postgresql.conf file, there is one line listen_addresses = '*' which was the default, but as I understand it it is what it needs to be so a non-localhost can connect to the database.
How can I do this? On my laptop I tried running psql and for the server I put the IPv4 address of my PC(where the local database is stored), but it doesn't connect (Connection timed out)
I'm trying to connect my local gui for postgres to a virtual server that I have running postgres.
I can
su postgres_user
Then
pgsql
Here pgsql loads.
When I go to my pg_hba.conf I have
host all all x.x.x.x/24 trust
In postgresql.conf
listen_addresses = 'localhost,x.x.x.x'
I have ubuntu 16 and postgres 9.5
I have the issue when I try to connect I get the error:
could not connect to server: Connection refused...Is the server running on host "hostip" and accepting TCP/IP connections on port 5432.
If you are using linode, you must either whitelist your ip or use putty (in windows) to tunnel postgres to connect to it.
putty tunneling is easier, however more annoying to deal with on a day to day basis
Follow the tutorial here.
here
Note, it's the same for PGAdmin as it is for any gui in windows.