I am always getting connection refused error,

while if I connect via dbeaver its get successful. Please help me with what am I missing here. I have tried via tunnel-ssh, pg. Still same issue.
const { Client } = require('ssh2');
const postgres = require("postgres");
// SSH Configuration
const sshConfig = {
host: '143.xx.xxx.xx',
port: 22,
username: 'root',
password:"*****"
};
// PostgreSQL Database Configuration
const dbConfig = {
user: 'postgres',
host: 'localhost', // This is localhost because we're using an SSH tunnel
database: 'postgres',
password: '******',
port: 30432, // PostgreSQL port on the remote server
};
// Create an SSH tunnel
const sshTunnel = new Client();
async function getUsersOver(sql) {
const users = await sql`
select
*
from users
`
// users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]
return users
}
sshTunnel.on('ready', () => {
sshTunnel.forwardOut(
'localhost', // Local address
dbConfig.port, // Local port (automatically assigned)
dbConfig.host, // Remote address (the database host)
dbConfig.port, // Remote port (the PostgreSQL port on the remote server)
(err, stream) => {
if (err) throw err;
// Create a PostgreSQL client connected through the SSH tunnel
const dbClient = postgres({...dbConfig, stream});
getUsersOver(dbClient)
}
);
});
sshTunnel.connect(sshConfig);