# Postgres Service

URL: /docs/services/postgres

Source: https://github.com/easypanel-io/monorepo/blob/main/apps/website/content/docs/services/postgres.mdx

Run and operate a persistent PostgreSQL database.



The Postgres service runs the official PostgreSQL Docker image with persistent
storage, generated credentials, connection URLs, optional browser
administration tools, scheduled backups, and resource controls.

## Create a Postgres service [#create-a-postgres-service]

1. Open a project and select **New Service**.
2. Select **Postgres** and enter a service name.
3. Optionally set the database name, user, password, and Docker image.
4. Create the service and wait for it to start.
5. Open **Credentials** and copy the internal connection URL into the
   application that needs the database.

When omitted, the database name defaults to the project name, the user defaults
to `postgres`, and Easypanel generates the password. Leaving the image empty
uses Easypanel's default official PostgreSQL image.

## Overview [#overview]

The overview provides start, stop, logs, notes, and destroy actions. Its Shell
menu can open Bash or `psql` as the `postgres` user.

The page also shows runtime metrics, recent logs, detected errors, and two
optional administration tools:

* **PgWeb** provides a PostgreSQL browser interface.
* **DbGate** provides a general database browser.

Enable a tool only when needed and disable it afterward. Easypanel gives each
tool a generated access token and a dedicated domain.

## Credentials [#credentials]

The Credentials tab shows:

* user and password;
* database name;
* internal host and port `5432`;
* internal connection URL with `sslmode=disable`;
* external host, port, and connection URL when the service is exposed.

Services in the same Easypanel project should use the internal connection URL.
The internal host is derived from the project and service names and is
reachable on the private service network.

Select **Edit** to change the database password. Easypanel updates the
PostgreSQL role and redeploys connected PgWeb or DbGate tools. Update every
application that uses the old password.

<Callout type="warn">
  The current credential rotation flow targets the default `postgres` role. Do
  not use it for a service created with a custom username.
</Callout>

<Callout type="warn">
  The generated connection URL disables TLS because it targets the private
  service network. If you expose PostgreSQL publicly, protect the connection at
  the network layer and configure database TLS when your threat model requires
  it.
</Callout>

## Expose [#expose]

PostgreSQL is private by default. The Expose tab publishes it on the server so
that an external database client can connect. Saving the exposed port restarts
the service and adds external values to the Credentials tab.

Prefer the internal connection for applications hosted in Easypanel. If remote
access is required, restrict the port with the server or provider firewall and
use a unique published port.

## Backups [#backups]

The Backups tab creates logical database backups in a configured storage
provider. A backup configuration includes the database name, enabled state,
cron schedule, retention count, storage provider, and destination path.

You can run a backup immediately, edit or remove its schedule, restore a backup
file, and review the backup action log. Configure the destination first under
the server's storage provider settings.

Test a manual backup and restore on non-production data before relying on a
schedule. See [Database Backups](/docs/backups/database) for destination setup,
retention behavior, and restore precautions.

## Resources [#resources]

Configure memory reservations and limits in MB, and CPU reservations and limits
in cores. Set a value to `0` for unlimited resources. Saving these settings
restarts the service.

Leave headroom for maintenance, index creation, backups, and peak query load. An
aggressive memory limit can terminate PostgreSQL and interrupt transactions.

## Advanced [#advanced]

Advanced settings can override the Docker image and command and add environment
variables using `.env` syntax. Saving Advanced settings redeploys the database.

Use a command override only when you understand the image entrypoint. Put
supported PostgreSQL image variables in Environment.

<Callout type="warn">
  Image, command, and environment changes can prevent PostgreSQL from starting
  or make an existing data directory incompatible. Major PostgreSQL upgrades
  require a supported migration process, not only a new image tag.
</Callout>

## Data and deletion [#data-and-deletion]

PostgreSQL stores its data on the server at:

```text
/etc/easypanel/projects/[project]/[service]/data
```

The directory is mounted at `/var/lib/postgresql/data` in the container.
Destroying the service permanently removes its database files and
configuration. Verify an external backup before confirming deletion.
