How can I open postgresql for remote connections

I ran PostgreSQL on replit by following this tutorial

Now I want to connect to this database from another repl.

I made these changes to open it for remote connections

  • ran the postgres server on host and
  • Set listen_addresses = '*' in postgresql.conf
  • Added these two lines in pg_hba.conf (I know that it is not safe)
host    all             all                   trust
host    all             all              ::/0                         trust

Now I find the repl’s public IP by curl
Then I go to a different repl and try connecting to postgres using the command:
psql -h $IP -p 5432

But it fails with the following error

psql: error: connection to server at "", port 5432 failed: Operation timed out
	Is the server running on that host and accepting TCP/IP connections?

I believe this is because the port is closed by the firewall. However, running it on port 80 also does not work.
What can I do to allow connections from other IPs?