> For the complete documentation index, see [llms.txt](https://docs.ngsurvey.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ngsurvey.com/installation-setup/installation/database-backend/postgresql.md).

# PostgreSQL

Using the Postgres storage engine you can use any Postgres based database as your ngSurvey backend.&#x20;

## Requirements

To install  ngSurvey on a Postgres database you will need to meet following requirements

1. Postgres version 16.x or above.
2. User used to connect to the Postgres server must have enough privileges to to create a new database.&#x20;

## NGSurvey configuration

In order to configure ngSurvey to work with Postgres you need to setup following environment variables.

{% hint style="info" %}
NGSurvey will automatically create or update the database that you have specified in the connection string. By default ngSurvey will use "postgres" as the maintenance database if you would like to change the maintenance database that is used during creation of the new ngsurvey database you can change it using following environment variable : NGSurvey:PGMaintenanceDB
{% endhint %}

* **`ConnectionStrings:NGSurveyDB`** holds your connection string to your Postgres server.
* **`NGSurvey:StorageEngine`** must be set to *Postgres.*

## Entra Managed Identity

To use an Entra Managed Identity to authenticate your connection to Postgres, you may specify the set the Entra username in the PostgreSQL connection string without any passwords. Ensure this user has the proper access rights in your PostgreSQL database and that you are using a Flexible Server Host for your PostgreSQL database.

## Health check

Once you have configured your database settings you may re-start the web service hosting ngSurvey. NGSurvey will automatically setup the database will all the required tables.

You may also check if your installation is properly setup using following link :\
<https://yourrootsite/api/system/status>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ngsurvey.com/installation-setup/installation/database-backend/postgresql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
