How to know which ip has connected to a postgresql database?

Asked

Viewed 275 times

-1

The question is the same as the title:

How to know which ip has connected to a postgresql database?

It’s just that I’ve cleared the external access and I need to have some control of where the access comes from.

  • Bad idea. Properly configure your file postgresql.conf and pg_hba.conf. Evaluate log configuration to identify possible unwanted accesses.

1 answer

0

You can use the query below. There will be the client_hostname column that will display the address of the connected client based on a DNS lookup Reverse. It will only present clients connected via ip.

SELECT * FROM pg_stat_activity WHERE state = 'active';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.