To enable PostgreSQL to listen to remote connections, you need to edit your defaults file. To do this, open the console in your PostgreSQL LXC
```yaml
nano /etc/postgresql/13/main/postgresql.conf
```
Un-comment `listen_addresses` and replace localhost with * sign to allow all Ip-address to connect to the Database server.
```
listen_addresses = '*' # what IP address(es) to listen on;
```
Save and exit the editor with "Ctrl+O", "Enter" and "Ctrl+X".
```yaml
nano /etc/postgresql/13/main/pg_hba.conf
```
Change values to match as shown below
```
# Database administrative login by Unix domain socket
local all postgres md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::0/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
```
Save and exit the editor with "Ctrl+O", "Enter" and "Ctrl+X".
Restart the Database server to apply the changes:
```
sudo systemctl restart postgresql
```
To make sure our PostgreSQL is secured with a strong password, set a password for its system user and then change the default database admin user account
Change user password
```yaml
passwd postgres
```
Login using Postgres system account
```
su - postgres
```
Now, change the Admin database password
```
psql -c "ALTER USER postgres WITH PASSWORD 'your-password';"
```
Create a new user.
```yaml
psql
```
```yaml
CREATE USER admin WITH PASSWORD 'your-password';
```
Create a new database:
```yaml
CREATE DATABASE homeassistant;
```
Grant all rights or privileges on created database to the user
```yaml
GRANT ALL ON DATABASE homeassistant TO admin;
```
To check that the database has been created
```yaml
\l
```
Change the recorder: `db_url:` in your HA configuration.yaml
⚙️ [**Adminer**](https://raw.githubusercontent.com/tteck/Proxmox/main/misc/images/adminer.png) (formerly phpMinAdmin) is a full-featured database management tool