diff --git a/docs/content/development/backend/configurations.md b/docs/content/development/backend/configurations.md index 69b998a6c8..b8b94f1192 100644 --- a/docs/content/development/backend/configurations.md +++ b/docs/content/development/backend/configurations.md @@ -44,7 +44,23 @@ module.exports = { } ``` -Where `database_type` is `postgres` and `DATABASE_URL` is the URL connection string to your PostgreSQL database. You can check out how to format it in [PostgreSQL’s documentation](https://www.postgresql.org/docs/current/libpq-connect.html). +Where `database_type` is `postgres` and `DATABASE_URL` is the URL connection string to your PostgreSQL database. The connection URL should be of the following format: + +```bash +postgres://[user][:password]@[host][:port]/[dbname] +``` + +Where: + +- `[user]`: (required) your PostgreSQL username. If not specified, the system's username is used by default. +- `[:password]`: an optional password for the user. When provided, make sure to put `:` before the password. +- `[host]`: (required) your PostgreSQL host. When run locally, it should be `localhost`. +- `[:post]`: an optional port that the PostgreSQL server is listening on. By default, it's `5432`. When provided, make sure to put `:` before the port. +- `[dbname]`: (required) the name of the database. + +For example, the connection URL can be `postgres://postgres@localhost/medusa-store`. + +You can learn more about the connection URL format in [PostgreSQL’s documentation](https://www.postgresql.org/docs/current/libpq-connect.html). It's recommended to set the Database URL as an environment variable: @@ -59,7 +75,7 @@ Where `` is the URL of your PostgreSQL database. By default, the `public` schema is used in PostgreSQL. You can change it to use a custom schema by passing the `search_path` option in the database URL. For example: ```bash -postgres://localhost/store?options=-c search_path=test +postgres://postgres@localhost/store?options=-c search_path=test ``` Where `test` is the name of the database schema that should be used instead of `public`. diff --git a/docs/content/troubleshooting/database-errors/_connection-error.md b/docs/content/troubleshooting/database-errors/_connection-error.md index 05cfde6826..3660342fa9 100644 --- a/docs/content/troubleshooting/database-errors/_connection-error.md +++ b/docs/content/troubleshooting/database-errors/_connection-error.md @@ -7,4 +7,4 @@ Error: connect ECONNREFUSED ::1:5432 This error occurs because the backend couldn't connect to the PostgreSQL database. The issue could be one of the following: 1. PostgreSQL server isn't running. Make sure it's always running while the Medusa backend is running. -2. The connection URL to your PostgreSQL database is incorrect. This could be because of incorrect credentials, port number, or connection URL format. The format should be `postgresql://[user[:password]@][host][:port][/dbname][?paramspec]`. Make sure that the connection URL format is correct, and the credentials passed in the URL are correct. +2. The connection URL to your PostgreSQL database is incorrect. This could be because of incorrect credentials, port number, or connection URL format. The format should be `postgres://[user][:password]@[host][:port]/[dbname]`. Make sure that the connection URL format is correct, and the credentials passed in the URL are correct. You can learn more about formatting the connection URL [here](../../development/backend/configurations.md#postgresql-configurations)