Setting up pglogical over ssh tunnel, connection reset by peer - postgresql

I am setting up a pglogical replication between an on-premise PostgreSQL 10.14 (publisher and AWS RDS Postgresql 10.16 (subscriber), but after setting up a subscription, I only get to connection resets. Can anyone spot what I'm doing wrong?
Network setup:
On-premise postgres < jumphost > <-- ssh tunnel --> AWS RDS
internal-ip 10.2.0.8 db01.some.tld
I have verified that the ssh tunnel is working:
I can connect to the on-premise postgres from AWS using psql connecting to the tunnel
I can even connect to the on-premise postgres from AWS RDS when using postgres_fwd
Pglogical setup:
on-premise:
create node with dsn host=10.2.0.8 dbname=... user=... password=...
AWS:
create node with dsn host=db01.some.tld dbname=... user=... password=...
create subscription with dsn host=10.2.0.8 dbname=... user=... password=...
Once that is done:
pglogical processes are running on both the provider and subscriber
but I get to the following errors:
AWS:
LOG: could not receive data from client: Connection reset by peer
LOG: unexpected EOF on client connection with an open transaction
On-premise:
LOG: unexpected EOF on client connection with an open transaction
I have tried fiddling around with logging parameters, but couldn't get to anything useful. Similarly I couldn't get anything helpful from the ssh tunnel logs.
Any idea what I could be doing wrong?

Figured it out. In this case:
The connection was fine. However, there was an issue with the schema of one table on the replica, causing the replication to die.

Related

Can't connect to PostgreSQL server from AKS

I've created an AKS cluster and Flexible PostgreSQL database.
The postgresql database is public, and I made firewall entry while setting up the DB to allow local connection from my IP - which worked fine.
When I then tried to connect from AKS, I was unable to - I was getting timeouts.
Eventually, I clicked the setting to allow access from everywhere on azure
That fixed the timeouts, and I can now connect, but I get a new error:
no pg_hba.conf entry for host "**.**.***.203"
What am I doing wrong?

pgAdmin is throwing Error saving properties unable to connect server timeout expired connecting to Postgresql in AWS Lightsail

I have a Linux instance in AWS Lightsail and I have started up a PostgreSQL database on my LightSail hosted Linux server. On my local Windows 10 machine, I have a Postgresql server as well. When I am attempting to connect to the AWS Postgresql server on Lightsail following the steps described here:
https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-connecting-to-your-postgres-database
On my pgAdmin (my pgAdmin is acting as the client while the Postgresql database that I have on AWS is the server), I am seeing the following error message:
Error saving properties
Unable to connect to the server:
timeout expired
Please note, my database is hosted by Lightsail and not by AWS RDS.
use SSL tunnel with your ip and pem file under SSH Tunnel Tab
Under connection user the ip 127.0.0.1 with your postgres username and password.

Error no pg_hba.conf entry for host when using PG client, but not when connecting with psql?

I'm pointing my application from one PG cluster to another (changing the team that manages the PG cluster), and I'm getting connection errors when trying to connect with a language binding for javascript:
no pg_hba.conf entry for host xxx.x.x.x, user "blah", database "blah", SSL off
I'm led to believe that this is a pg_hba.conf configuration error, but I can connect to the cluster with psql, from the same machine, with the same credentials.
psql: 9.5.7,
PG cluster 10.5
Client: pg-promise 9.3.3
How can this be possible? Is this still definitely an issue with how pg_hba.conf is set up or is there something wrong with how I configured my client? This is not the first time I've used it, I've been connecting to a PG cluster v. 9.5.7 for the last couple of years.
The issue was that the new cluster is using SSL for the connection. When I connected to the old cluster, there was no SSL, so the connection worked with my current config, but when switching to the new cluster I had to specify that SSL was being used.
https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax

PGAdmin III cannot connect AWS RDS

I am trying to connect AWS RDS PostgreSql from PgAdmin 3. I followed the below link
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html
In Security Group, I also added PostgreSQL and All traffic as below
The "publicly accessible" flag was enabled (updated after Mark B's comment)
I got the error from PGAdmin3
Very appreciate for any suggestion
******UPDATE*******
I can connect pgAdminIII to AWS RDS successfully using home wifi, but cannot connect using office wifi.
My concern is:
Was the port 5432 blocked by office wifi?
How can I configure/update the port without impacting to current API?
Note: My current API is working well (CRUD)
Can you can test your connection to a DB instance using common Linux or Windows tools first?
From a Linux or Unix terminal, you can test the connection by typing the following (replace with the endpoint and with the port of your DB instance):
$nc -zv DB-instance-endpoint port
For example, the following shows a sample command and the return value:
$nc -zv postgresql1.c6c8mn7tsdgv0.us-west-2.rds.amazonaws.com 8299
Connection to postgresql1.c6c8mn7tsdgv0.us-west-2.rds.amazonaws.com
8299 port [tcp/vvr-data] succeeded!
Windows users can use Telnet to test the connection to a DB instance. Note that Telnet actions are not supported other than for testing the connection. If a connection is successful, the action returns no message. If a connection is not successful, you receive an error message such as the following:
C:>telnet sg-postgresql1.c6c8mntzhgv0.us-west-2.rds.amazonaws.com
8299
Connecting To sg-postgresql1.c6c8mntzhgv0.us-west-2.rds.amazonaws.com...Could not
open connection to the host, on port 819: Connect failed
If Telnet actions return success, then you are good to go.
If you are trying to access it from a network which is not listed for that port. you need to add inbound rules for those network IPs from AMAZON RDS system
You will also need to set Public accessibility true under Connect & security tab in RDS console.
Read this post.In your security group go to unbound rules and add my ip.
and make sure your database is public.
https://serverfault.com/questions/656079/unable-to-connect-to-public-postgresql-rds-instance

RDS Postgresql DB connection timeout from Heroku

I'm unable to connect to a new PostgreSQL in AWS RDS.
I have a Heroku app and I would like to use Amazon RDS for my database instead of Heroku. For that I've been following this guide: https://www.reinteractive.net/posts/128-heroku-app-backed-by-an-aws-rds-postgres-database
I've made a backup from my current Heroku DB and want to load it on the new database.
My security group for the database allows all inbound connections for port 5432 (0.0.0.0/0) and I've made a new VPC to have my DB set as Publicly Accesible (DNS hostnames and DNS resolution enabled). I created the database on postgres version 9.4.9.
However when I do:
-f latest.sql --host=xxx.xxx.us-west-2.rds.amazonaws.com --port=5432 --username=awsuser --password --dbname=mydatabase
from my computer, I only get a connection time out error:
psql: could not connect to server: Connection timed out
Is the server running on host xxx.xxx.us-west-2.rds.amazonaws.com" (1.2.3.4) and accepting
TCP/IP connections on port 5432?
The server is indeed running. In this case latest.sql is the backup I did. After this I edited the Database security groups to accept all connections (0.0.0.0/0) too.
Database Rules
(from what I've read this should not be necessary because I already have the VPC Security Group), but the result is the same.
Is there any way to trace what's going on / why is my connection getting blocked?