Skip to content
ContactWebmailCustomer panel

Hosting and Servers

How do I create a PostgreSQL database in Plesk and connect it to my application?

Short answer: you create a PostgreSQL database in Plesk the same way as a MySQL database: Websites & Domains → Databases → Add Database, type PostgreSQL, a database name, and a user with a password. An application on the same server connects to the host localhost (or 127.0.0.1) on port 5432. The most convenient way to pass this to it is as a single address, postgres://użytkownik:hasło@127.0.0.1:5432/baza, in an environment variable. The database is included in the subscription backup along with the site's files.

PostgreSQL or MariaDB/MySQL?

WordPress, WooCommerce, and PrestaShop need MySQL/MariaDB — for them, the choice is simple. PostgreSQL is usually chosen for custom applications:

This table can be scrolled horizontally.

PostgreSQLMariaDB / MySQL
Typical useNode.js, Ruby on Rails, Django, Laravel applications; analyticsCMSes and stores (WordPress, WooCommerce, PrestaShop)
Data typesJSONB, arrays, ranges, geographic types (PostGIS)JSON, basic types
SQL compliancevery good, transactions cover schema changes toogood, more of its own syntax extensions
Support in Pleskcreating databases and users, backupsthe same, plus phpMyAdmin

Creating a database and user in Plesk

  1. Open Websites & Domains and select Databases next to the domain.
  2. Click Add Database.
  3. Enter a database name (e.g. app_prod) and choose PostgreSQL as the database server.
  4. Create a database user: a name, a strong password (ideally generated by the panel).
  5. Save. The database and user are ready immediately.

For a staging environment, create a separate database and a separate user (e.g. app_staging) — don't use the production database for testing.

Host, port, and credentials

This table can be scrolled horizontally.

ParameterValue
Host127.0.0.1 (or localhost)
Port5432
Databasethe name given when creating it
User / passwordthe database user from the panel

The connection string in standard format:

postgres://app_user:TWOJE_HASLO@127.0.0.1:5432/app_prod

If the password contains special characters (@, :, /), encode them in the address (e.g. @ → %40). Store the address in the application's environment variable, e.g. DATABASE_URL, not in your code.

You can test the connection from the SSH console:

PGPASSWORD='TWOJE_HASLO' psql -h 127.0.0.1 -U app_user -d app_prod -c 'select version();'

Connecting from a Node.js application

The pg library, written in pure JavaScript, needs no compilation:

// npm install pg
const { Pool } = require('pg');

const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
  max: 5,                       // na hostingu wystarczy kilka połączeń
});

async function main() {
  const { rows } = await pool.query('select now() as teraz');
  console.log(rows[0].teraz);
}

main().finally(() => pool.end());

We describe how to run the application itself in the panel in our guide Node.js in Plesk.

Connecting from a Ruby application

In Ruby, the standard is the pg gem (it requires compilation during installation):

# Gemfile: gem "pg"
require "pg"

conn = PG.connect(ENV.fetch("DATABASE_URL"))
puts conn.exec("select now() as teraz").first["teraz"]
conn.close

In Ruby on Rails, a DATABASE_URL in the environment variables and the postgresql adapter in config/database.yml are all you need. We cover native gems and their limitations on hosting in our guide Ruby in Plesk.

Backup and restore

  • The subscription backup in Plesk's Backup Manager includes PostgreSQL databases along with the site's files. Restoring returns the database to its state at the time the backup was taken — we verified this on our test account.
  • Your own dump before a major change (schema migration, data import) — take it from the console:
PGPASSWORD='TWOJE_HASLO' pg_dump -h 127.0.0.1 -U app_user -Fc app_prod > app_prod-$(date +%F).dump
# odtworzenie do tej samej lub pustej bazy:
PGPASSWORD='TWOJE_HASLO' pg_restore -h 127.0.0.1 -U app_user -d app_prod --clean --if-exists app_prod-2026-09-17.dump

Keep dumps outside the site's public directory and delete old ones — they're a full copy of your data.

Security and external access

  • Isolation: a database user only has access to their own databases; trying to connect to someone else's database fails with a permissions error.
  • Internet access: the PostgreSQL server only accepts local connections. From your own computer, connect through an SSH tunnel if your package includes SSH access:
ssh -L 15432:127.0.0.1:5432 uzytkownik@twojafirma.pl
# potem lokalnie: psql -h 127.0.0.1 -p 15432 -U app_user -d app_prod
  • Passwords: a separate user for each application, generated passwords, kept in environment variables.
  • Permissions: the application doesn't need superuser rights — permissions on its own database are enough.

Common problems

  • "password authentication failed" — wrong password, or the user was created for a different database.
  • "permission denied for database" — the user isn't assigned to this database; add them to it in the panel.
  • "connection refused" — you're connecting from outside, or using the wrong port; from an application on the server, use 127.0.0.1:5432.
  • Special characters in the password break the address — encode them in the connection string, or pass the parameters separately.
  • "too many connections" — reduce the connection pool in your application (e.g. max: 5).

FAQ

Can I have both MySQL and PostgreSQL databases in one subscription?

Yes. You choose the type separately for each database; the database limit in your package covers both types.

Can I connect to the database from my own computer?

Not directly — the server only accepts local connections. Use an SSH tunnel, or work on a local copy of the database instead.

Is a PostgreSQL database included in the backup?

Yes, the subscription backup in Plesk includes a dump of the PostgreSQL database and lets you restore it.

Which PostgreSQL version should I choose?

On shared hosting, the server version is set by the administrator. Check it with the query select version(); and match your application's libraries to it.

Technical verification: 17 September 2026, Plesk Obsidian 18.0.80, PostgreSQL 13.23, Plesk subscription backup and restore. Related guides: Node.js applications in Plesk, Ruby applications in Plesk, Docker and Docker Compose in Plesk. Packages: NVMe hosting (Business) and NVMe Performance and Pro.