PostgreSQL connection error when DB_SSL_MODE is omitted in AdonisJS production
0 reputation · 12 Oct 2022, 00:51 UTC
When developing an AdonisJS application locally with SQLite, the server starts and migrations run without any additional configuration.
In production, switching the database driver to PostgreSQL by setting DB_CONNECTION=pg causes the Lucid ORM to throw a connection error during the first query or migration if DB_SSL_MODE is not explicitly defined.
The goal is to determine the correct SSL mode setting that allows the application to connect to a managed PostgreSQL service that enforces TLS, while preserving the ability to run locally with SQLite.
What DB_SSL_MODE value should be used for a hosted PostgreSQL that requires TLS? Should this variable be defined globally in .env or overridden per connection? How can the framework provide a clearer early‑warning message when SSL mode is missing?