Closed aleeusgr closed 3 months ago
The error message is indicating that the :database-url
environment variable is not set, which is required for the PostgreSQL database connection.
To fix this, you need to set the DATABASE_URL
environment variable. Here are a few ways to do so:
Option 1: Set environment variable in profiles.clj
In your project directory, open the profiles.clj
file and add the following code:
{:dev {:database-url "postgresql://username:password@localhost:5432/yourdatabase"}
:test {:database-url "postgresql://username:password@localhost:5432/yourdatabase"}}
Replace username
, password
, localhost
, 5432
, and yourdatabase
with your actual PostgreSQL credentials and database name.
Option 2: Set environment variable in config.edn
In your project directory, open the config.edn
file and add the following code:
{:database-url "postgresql://username:password@localhost:5432/yourdatabase"}
Again, replace the placeholders with your actual PostgreSQL credentials and database name.
Option 3: Set environment variable as an OS environment variable
You can set the DATABASE_URL
environment variable as an operating system environment variable. The exact steps vary depending on your OS:
export DATABASE_URL="postgresql://username:password@localhost:5432/yourdatabase"
set DATABASE_URL=postgresql://username:password@localhost:5432/yourdatabase
After setting the environment variable, restart your REPL or run your app again.
Choose the option that best fits your needs, and you should be able to connect to your PostgreSQL database successfully!