Can you share the logs for Daml on SQL on both VMs? Note that while you can connect them to the same postgres cluster they must use separate databases. So if you’re literally connecting to the same database (same host, port & database name) for both that may explain your issue.
I am connecting the 2 VMs to the same database, so that is the error. Should I create 2 databases for each daml environment? But then, how can I connect the two different databases? My idea is to create contracts with VM A and store them in postgres. VM B sees those contracts, acts on them, and stores them in postgres. Later VM A and VMB can see them.
Daml on SQL 1.x is a single participant ledger so you cannot share contracts between the two. The 2.x Daml on SQL can do this however, take a look at What became of `daml-on-sql.jar` in 2.x.x? - #2 by Stephen for instructions on using it.
For the purposes of flowcharts like this, it’s probably better to think of Daml itself as the underlying database for your apps. In other words, this flow chart would work:
---> JSON API <-> App
/
PostgreSQL <-> Daml <----> JSON API <-> App
\
---> gRPC App