Postgresql: Select a table from different database and different host
The second error message means, that your Postgres on db_name2 is not configured to allow connections from IP_db1. Unrelated to this problem: with modern Postgres versions it's usually better to use a foreign table, rather than the dblink module. – a_horse_with_no_name

You need to edit your pg_hba.conf file on the far host (x.x.x.x) to allow the connection. Don't forget to reload the server config files after for it to take effect. It is probably better to debug connection issues with "psql" rather than using dblink or postgres_fdw, those are just going to confuse the issue. – jjanes