I am having two containers running on host machine, the two containers are communicating over the network e.g --network=kafka-sink-connect and the containers communication happening as expected but when I am trying to create connector instance with below config
{
    "name": "jdbc-sink-connector",
    "config": {
        
        "connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
        "tasks.max": "1",
        "topics": "test.table",
        "key.converter": "org.apache.kafka.connect.storage.StringConverter",
        "value.converter": "org.apache.kafka.connect.json.JsonConverter",
        "value.converter.schema.registry.url": "http://schema-registry:8081",
        "schemas.enable": "false",
        "connection.url": "jdbc:postgresql://localhost:5432/postgres",
        "connection.username": "postgres",
        "connection.password": "*******",
        "insert.mode": "upsert",
        "batch.size": "1",
        "auto.create": true,
        "auto.evolve":true,   
        "table.name.format": "test.table",
        "errors.tolerance": "all",
        "errors.retry.delay.max.ms": 60000,
        "errors.retry.timeout": 300000,
        "errors.log.enable": true,
        "errors.log.include.messages": true
    }
}
I am getting the connection refused exception org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
I tried to change connection host and used host.docker.internal like
"connection.url": "jdbc:postgresql://host.docker.internal:5432/postgres"
in this case I am getting the error
org.postgresql.util.PSQLException: FATAL: role "root" does not exist
 
    