Postgresql – invalid integer value “CONNECTION” for connection option “port” Previous connection kept

postgresqlpostgresql-12replication

I'm new to postgres and I'm trying to configure table level logical replication(PUBLICATION/SUBSCRIPTION) on postgres-12.

I have updated postgresql.conf file and updated wal_level=replica. Also, then created 2 databases(test1 and test2). Here is what , I'm doing:

test1=# create table t1(a int primary key, b int);
CREATE TABLE
test1=# insert into t1 values(1, 1);
INSERT 0 1
test1=# create publication my_pub for table t1;
CREATE PUBLICATION

test2=# CREATE TABLE t1(a int primary key, b int);
CREATE TABLE
test2=# CREATE SUBSCRIPTION my_sub CONNECTION 'host=localhost port=5432 dbname=test2 user=postgres 
password=password' PUBLICATION my_pub;
invalid integer value "CONNECTION" for connection option "port"
Previous connection kept

When creating subscription I'm getting this message: invalid integer value "CONNECTION" for connection option "port"
Previous connection kept and I'm unable to add this table into replication. In my postgresql.conf file as well I have mentioned 5432 port only. However, I'm unable to understand why it's saying invalid integer value

Best Answer

It seems to me that what you really must have done is something like:

\c CREATE SUBSCRIPTION my_sub CONNECTION ...

The arguments to \c are positional, and the 4th position belongs to the port.

I see no other way your message could include 'Previous connection kept', which is exclusively generated by attempts to use \c or \connect