Configuring pgAdmin 4 for PostgreSQL Administration

Manual edits in databases and scattered access slow down the team and create a risk of failures. We configure pgAdmin 4 turnkey: we streamline roles, access, and connections so administrators spend less time on routine tasks. We automate some operations—manual actions and session interruptions become noticeably fewer.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1359
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

Configuring pgAdmin 4: where database administration breaks

pgAdmin 4 is adopted as a quick way to look into a database: connecting to PostgreSQL via a graphical client takes minutes, and at that point setup is usually considered complete.

Everything breaks later — when several people work through the same interface, and the server follows its own maintenance schedule.

The first thing to fail is the connection. The graphical client keeps the session open while a query is running, and when connectivity is lost, it returns not the result but a database connection error.

A dropped session during a long operation is most frustrating because the administrator no longer knows which part of the changes reached the server, and must check manually. A reasonable session hold time eliminates some of these drops, but does not eliminate them entirely.

The second is superuser privileges. A single shared account for the team is convenient right up until the first incident: logs show that an object was changed, but not who exactly did it.

Manual edits instead of a procedure accumulate, the schema diverges from the documentation, and database administration turns into dealing with the aftermath.

We break down how this is addressed: connection parameters and session hold time, separate roles for specific tasks instead of one universal role, a change procedure, and a log that shows the author. Below is what exactly is configured and in what order.

What changes after bringing order to database access

The time for a typical operation — granting access to a new engineer, expanding a role's privileges, revoking a contractor's access — drops from tens of minutes to one or two.

Privileges are assigned by a pre-defined role rather than assembled step by step, so the number of manual steps decreases from eight or ten to one.

Access recovery time after a failure is also measured in minutes: the connection and role configuration is stored alongside the project, and a new engineer replicates it rather than reconstructing it from memory.

Access separation stops being a set of verbal agreements — the role answers what can be read, what can be changed, and until when.

The action log records who connected and when, what queries they ran, and what they changed in the schema. Incident analysis is based on the log, not on participants' recollections, and this removes a whole class of "it wasn't us" disputes.

A class of failures that accumulates over years also goes away: a shared superuser account, forgotten contractor access, debug privileges left after a release.

Connection resilience is provided by a connection pool, timeouts, and retries — one client failing does not bring down the others.

In a managed environment, pgAdmin 4 is configured declaratively: servers, roles, and privileges are described by configuration and transferred between environments without manual reconciliation.

A new workstation is deployed in one operation, and rollback to the previous state remains possible.

Database connection methods: direct access, tunnel, gateway

The method of access to the database server determines who can intervene in an incident, how quickly, and how widely the environment is exposed.

In pgAdmin 4, connection setup comes down to four stable patterns: direct connection, secure tunnel, centralized gateway, and a local client on the engineer's machine. The choice between them is a trade-off between speed of work and access manageability.

Option When it fits Limitations
Direct connection Server in a closed network segment, engineers in the same environment Database is accessible to anyone who ends up on the network; no shared connection log
Secure tunnel Remote work, one or two administrators Keys and access are scattered across machines; when an engineer leaves, there is nothing to revoke
Centralized gateway Distributed team, multiple environments and test setups The gateway itself must be maintained; it is a separate point of failure
Local client One-off analysis, training, debugging heavy queries Data remains on the workstation; no access control or audit

What to consider when choosing

Direct connection and a local client are justified where the environment is already closed off by network segmentation and there is a single administrator.

A secure tunnel addresses remote access but does not provide the full picture: privileges live on machines, not in one place.

For a distributed team and multiple environments, a centralized gateway is used — it maintains a single access list, a shared connection log, and revokes access with one action.

Under high database load, the gateway is moved to a separate node so administrative traffic does not compete with application queries.

Implementation order and setup of the working environment

Implementation goes from access inventory to handover of the support environment: configuring privileges on top of an unknown role picture almost always produces excessive privileges. Each step leaves an artifact by which the result can be verified.

  1. Access audit. We collect accounts, servers, and databases, mark privileges granted "just in case," and accounts used by several people.
  2. Role model. We form groups by task — reporting, development, operations, audit — and assign privileges by group rather than by person.
  3. Connection setup. We add servers in pgAdmin 4, set connection parameters, read-only mode, and secure storage of credentials instead of plaintext passwords.
  4. Validation on a database copy. We run scenarios on a restored copy of the working database: you can see how privileges and heavy queries behave, while the working database is untouched.
  5. Team training. We show engineers and analysts typical operations in the configured environment and leave a short cheat sheet.
  6. Documentation handover. We provide role descriptions, connection schemas, and the procedure for changing privileges — the environment can evolve without us.

Acceptance criteria

The work is accepted when the environment can be raised from the documentation on a clean setup, there are no excessive privileges in the account list, and the roles cover the declared scenarios.

We separately verify access revocation: when an employee leaves, it is closed in one operation, without manually going through databases.

What we hand over: configurations, schemas, and procedures

We hand over not only the working environment but also a set of artifacts that allow it to be maintained without us. Each document covers its own class of tasks: deployment from scratch, access provisioning, and incident analysis by the on-call shift.

  • Server and client configuration files — connection parameters, timeouts, TLS mode, log paths: a new node is brought up reproducibly, not from an engineer's memory.
  • Role and privilege scheme: which servers, databases, and schemas each role sees in pgAdmin 4, where viewing is restricted, and where changes are allowed.
  • Address-based access rules: whitelists at the server and access-file level, subnet binding, prohibition of direct connections from outside the perimeter.
  • Templates for typical connections for development, analytics, and the on-call shift — connection in two actions, without manual address entry.
  • Instructions for the on-call engineer: what to check when a node is unavailable, how to restart the service, where the logs are, and when to escalate.
  • Procedure for granting and revoking access: request, term, confirmation, deactivation when an employee leaves or changes role, scheduled review of the user list.
  • Configuration change log: what was changed, by whom, and why — so rollback of a failed change takes minutes, not hours of searching for the cause.

We update the set with every change to the environment so the documentation does not diverge from the actual state.

Case study: how manual operations and session drops were reduced

Before implementation, database access was granted manually: an engineer edited pg_hba.conf on the server, created a role, rebuilt the connection pool, and sent credentials via messenger.

For 40–50 such operations per week, up to two business days of waiting were spent — even though half of the requests were read-only.

After configuring pgAdmin 4, access is granted from a template: the role, group membership, and schema privileges are described by one profile, and the connection takes credentials from a secure file and requires no manual input.

Manual actions dropped to 6 per week instead of 40+ — mainly where privileges outside the template are needed.

Database connection time decreased from 6–8 to 1–2 seconds: server groups no longer recreate the connection for every query, and the pool keeps ready sessions.

The share of dropped sessions fell from 11% to 0.7% — the drops were caused by expired certificates and timeouts that no one had been monitoring before.

What turned out to be the bottleneck

"The administration tool itself was not the problem — the legacy of overgrown privileges got in the way: some roles still had excessive server-level privileges, and every connection pulled in checks that no one controlled.

Until the role model was consolidated into groups, any settings produced only a cosmetic effect," comments the engineer who led the implementation.

The result of implementation is a reproducible procedure: a new engineer deploys the working environment in one pass, access is revoked as quickly as it is granted, and questionable connections are visible in the log. Only approval of access to production data remains manual — now it takes minutes, not days.

How working in a graphical client differs from the console

The graphical client and console access solve different tasks, so in a mature environment both usually coexist. The client is needed where data must be seen and compared, while the console is needed where an operation must be repeated unchanged.

The choice is dictated not by a particular engineer's convenience, but by whether the result of the work remains reproducible.

The visual client wins in incident analysis. The query execution plan, index behavior, lock list, and table sizes are visible side by side without typing a dozen commands — the path from "the database responds slowly" to the cause is shortened.

Comparing two schemas, viewing a result set, or correcting a row in a reference table in the interface is faster and safer than composing a query manually.

The console and scripts are indispensable for repeatable operations. Changing server parameters, creating roles, migrations, table maintenance — anything done more than once is formalized as a script: it lives in version control, is reviewed before execution, and is repeatable.

In practice, this looks like: diagnostics and manual edits — in pgAdmin, regular changes and configuration — by script.

Access to the client is still granted through a tunnel and under a separate role with minimal privileges: a convenient interface does not cancel access separation and action logging.

A simple selection rule: an action is needed once — client; twice or more — script. Both tools are configured in the same infrastructure, and we usually cover them together — the client as the engineer's working tool, scripts as the source of truth about the database state.

Common technical concerns before starting work

Before starting work, clients raise the same set of questions — from the risk of restarting the production database to what will remain in access after an engineer leaves. Below are brief answers to each of them.

Will the setup require stopping a running database?

No. Most changes — connection parameters and privileges — are applied by rereading configuration files without restarting the process.

A full stop is needed only when changing shared memory parameters or the log format: we schedule such a window in advance and outside business hours.

Can visibility be separated by schema?

Yes. Privileges are granted at the schema and table level: a role sees only its own schemas, and new objects receive predefined default privileges.

In the admin interface, this appears as different sets of schemas for different accounts — anything extra is neither visible nor editable.

What to do when the team has an unstable connection?

We adjust session timeouts and connection waits to the actual channel latency, not default values. The connection pool and retries ensure that a short outage does not break work or leave hanging locks.

Does the database need to be exposed to the external network?

Not necessarily. The preferred path is a secure tunnel or private network: then the database port remains closed. If external access is still needed, we restrict the address list and enable connection encryption rather than opening the port to the outside.

What happens to access when an employee leaves?

Accounts are personal, not one shared account, so revocation means deleting one role or removing it from groups. We hand the client a role registry with assignments: privilege review takes minutes rather than searching through configurations.

Let's discuss the task: where we start and what we need from you

For the scope estimate to be substantive rather than a rough guess, access to servers is not needed at the start — a description of the environment is enough. The more accurate the input data, the fewer clarification rounds before work begins.

  • environment diagram: where the databases live, how many nodes and replicas, how environments are separated, and from where access to pgAdmin 4 is open;
  • list of roles: who administers, who only needs to view metrics and logs, who reads data;
  • description of incidents: what broke, how it was detected, how long recovery took;
  • current access procedure: where accounts are stored, whether there are shared ones, how privileges are granted and revoked;
  • logging requirements: which actions and for how long must be stored, who reads the history;
  • constraints: closed environment without an external network, approval procedure, change windows;
  • responsible person on the client side who confirms access and accepts the result.

Based on this set, we come back with a scope estimate and work plan: stages, the result of each, what is required from your side, and the order in which we start. Describe the task in free form — we will clarify the rest during the review.