Fixing exposed database
We need to find our postgresql.conf file. In my case, I found it in /Library/PostgreSQL/15/data/. Then we need to open this, for instance, with vim, but we won’t have the permissions to open this file. To access and edit it do:
sudo -u postgres vim /Library/PostgreSQL/15/data/postgresql.conf
and change '*' in listen_addresses = '*' to 'localhost'.
See comments here.