Skip to main content

PostgreSQL Datasource - Complete Guide

๐Ÿ”Œ Connect PostgreSQL Databaseโ€‹

Connection Details ยท SSL Configuration ยท Connection String ยท Testing


๐Ÿ“‹ Table of Contentsโ€‹


Overviewโ€‹

Jet Admin provides native PostgreSQL connectivity with full support for:

  • โœ… Standard PostgreSQL connections
  • โœ… SSL/TLS encrypted connections
  • โœ… Connection pooling
  • โœ… Custom connection parameters
  • โœ… Connection testing before saving
  • โœ… Encrypted credential storage

PostgreSQL Version Support: 9.4 and above


Connection Methodsโ€‹

Jet Admin offers two methods to connect to PostgreSQL:

Enter individual connection parameters (host, port, database, etc.)

Best for:

  • Standard database connections
  • When you need fine-grained control
  • SSL configuration requirements

Method 2: Connection Stringโ€‹

Provide a complete PostgreSQL connection URI

Best for:

  • Quick connections
  • Copy-pasting from hosting providers
  • Heroku, Railway, Supabase deployments

Connection Details Configurationโ€‹

When you select "Connection Details", you'll configure these fields:

Basic Connection Fieldsโ€‹

FieldTypeRequiredDefaultValidationDescription
Connection NameStringโœ… Yes-Min: 3 chars, Max: 255A unique name to identify this datasource in Jet Admin
HostStringโœ… Yes-Valid hostname or IPPostgreSQL server hostname or IP address
PortIntegerโŒ No54321 - 65535PostgreSQL server port number
DatabaseStringโœ… Yes-Min: 1 charName of the database to connect to
UserStringโœ… Yes-Min: 1 charPostgreSQL username for authentication
PasswordStringโœ… Yes--Password for the PostgreSQL user

Connection Nameโ€‹

Purpose: Identify this datasource within Jet Admin's datasource list.

Best Practices:

  • Use descriptive names: Production-Orders-DB not DB1
  • Include environment: Dev-Postgres, Staging-DB, Prod-Analytics
  • Keep it unique across your tenant

Examples:

โœ… Good: "Production-Postgres-Main"
โœ… Good: "Dev-Database-Orders"
โŒ Bad: "DB1"
โŒ Bad: "Test"

Hostโ€‹

Purpose: The PostgreSQL server address.

Accepted Formats:

  • Domain name: db.example.com
  • Subdomain: postgres.internal.network
  • IP address: 192.168.1.100
  • localhost: localhost (for local development)
  • AWS RDS: mydb.123456789012.us-east-1.rds.amazonaws.com
  • Heroku: ec2-54-123-45-67.compute-1.amazonaws.com
  • Supabase: dbabcdefghijklmnop.supabase.co

Important Notes:

  • For Docker deployments, use the service name (e.g., postgres)
  • For cloud databases, use the public endpoint provided
  • Ensure the server is accessible from Jet Admin's network

Portโ€‹

Purpose: TCP port for PostgreSQL connections.

Default: 5432 (standard PostgreSQL port)

Common Variations:

  • Standard PostgreSQL: 5432
  • Heroku PostgreSQL: Varies (provided in connection URL)
  • Custom installations: Any available port

When to Change:

  • Your PostgreSQL server uses a non-standard port
  • Multiple PostgreSQL instances on same server
  • Cloud provider assigns custom ports

Databaseโ€‹

Purpose: The specific database to connect to within PostgreSQL.

Requirements:

  • Must exist on the PostgreSQL server
  • User must have CONNECT privilege
  • Case-sensitive on some systems

Examples:

โœ… myapp_production
โœ… analytics_db
โœ… orders_database
โœ… jetadmin

Userโ€‹

Purpose: PostgreSQL role for authentication.

Best Practices:

  • Use dedicated user for Jet Admin (not postgres superuser)
  • Grant only required privileges (SELECT, INSERT, UPDATE, DELETE)
  • Avoid using superuser accounts in production

Recommended Privileges:

-- Create dedicated user
CREATE ROLE jetadmin WITH LOGIN PASSWORD 'secure_password';

-- Grant database access
GRANT CONNECT ON DATABASE mydb TO jetadmin;

-- Grant schema access
GRANT USAGE ON SCHEMA public TO jetadmin;

-- Grant table privileges
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO jetadmin;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO jetadmin;

Passwordโ€‹

Purpose: Authentication credential for the PostgreSQL user.

Security:

  • Stored encrypted in Jet Admin database (AES-256)
  • Never displayed in plain text after saving
  • Transmitted over encrypted connection (when SSL enabled)

Password Requirements:

  • Minimum 8 characters recommended
  • Include uppercase, lowercase, numbers, special characters
  • Rotate regularly (every 90 days recommended)

SSL Configurationโ€‹

SSL Mode Optionsโ€‹

SSL ModeDescriptionUse Case
disableNo SSL encryptionLocal development only
allowTry non-SSL, then SSLLegacy servers
preferTry SSL, then non-SSLDefault - Recommended
requireRequire SSL (no verification)Production with self-signed certs
verify-caRequire SSL + verify CAProduction with trusted CA
verify-fullRequire SSL + verify CA + verify hostMost Secure - Production

SSL Mode Detailsโ€‹

disableโ€‹

Encryption: โŒ None
Certificate Verification: โŒ None
Security Level: โš ๏ธ None

Use Only For: Local development with localhost PostgreSQL

prefer (Default)โ€‹

Encryption: โœ… Preferred
Certificate Verification: โš ๏ธ Optional
Security Level: โœ… Good

Use For: Most production deployments

requireโ€‹

Encryption: โœ… Required
Certificate Verification: โŒ None
Security Level: โœ… Good

Use For: Production with self-signed certificates

verify-caโ€‹

Encryption: โœ… Required
Certificate Verification: โœ… CA verified
Security Level: โœ…โœ… Better

Use For: Production with certificates from trusted CA

verify-fullโ€‹

Encryption: โœ… Required
Certificate Verification: โœ… CA + Host verified
Security Level: โœ…โœ…โœ… Best

Use For: High-security production environments


Advanced Optionsโ€‹

Additional Connection Parametersโ€‹

Jet Admin supports any PostgreSQL connection parameter via additionalOptions:

ParameterTypeDescriptionExample
connectTimeoutIntegerConnection timeout in seconds10
applicationNameStringApplication identifier sent to serverJetAdmin-App
searchPathStringDefault schema search pathpublic,analytics
sslcertStringPath to client SSL certificate/path/to/cert.pem
sslkeyStringPath to client SSL key/path/to/key.pem
sslrootcertStringPath to root CA certificate/path/to/ca.pem
optionsStringCommand-line options for PostgreSQL-c timezone=UTC

connectTimeoutโ€‹

Purpose: Maximum time to wait for connection establishment.

Type: Integer (seconds)

Default: 30 seconds

When to Adjust:

  • Slow networks: Increase to 60
  • Fast local network: Decrease to 5
  • Cloud databases with firewalls: 15-30

Example:

{
"additionalOptions": {
"connectTimeout": 15
}
}

applicationNameโ€‹

Purpose: Identify the application to PostgreSQL.

Benefits:

  • Track connections in pg_stat_activity
  • Filter logs by application
  • Set application-specific configurations

Example:

{
"additionalOptions": {
"applicationName": "JetAdmin-Dashboard"
}
}

Query Running Applications:

SELECT application_name, count(*) 
FROM pg_stat_activity
GROUP BY application_name;

searchPathโ€‹

Purpose: Default schema search order.

Use Case: When using multiple schemas

Example:

{
"additionalOptions": {
"options": "-c search_path=analytics,public"
}
}

Connection String Configurationโ€‹

Connection String Formatโ€‹

When you select "Connection String", provide a complete PostgreSQL URI:

postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&param2=value2]

Complete Exampleโ€‹

postgresql://myuser:mypassword@db.example.com:5432/mydb?sslmode=require&application_name=JetAdmin

Connection String Componentsโ€‹

ComponentFormatRequiredExample
Protocolpostgresql:// or postgres://โœ… Yespostgresql://
Userusernameโœ… Yesmyuser
Password:passwordโœ… Yes:mypassword
Host@hostnameโœ… Yes@db.example.com
Port:portโŒ No (default: 5432):5432
Database/dbnameโœ… Yes/mydb
Parameters?key=value&key2=value2โŒ No?sslmode=require

Special Characters in Passwordโ€‹

URL-encode special characters in passwords:

CharacterURL Encoding
@%40
:%3A
/%2F
?%3F
#%23
&%26
=%3D
+%2B
%%25

Example:

Password: my@pass:word
Encoded: my%40pass%3Aword
Connection String: postgresql://user:my%40pass%3Aword@host:5432/db

Common Connection String Examplesโ€‹

Local Developmentโ€‹

postgresql://postgres:password@localhost:5432/mydb

Heroku PostgreSQLโ€‹

postgresql://username:password@ec2-54-123-45-67.compute-1.amazonaws.com:5432/dbname?sslmode=require

AWS RDSโ€‹

postgresql://admin:password@mydb.123456789012.us-east-1.rds.amazonaws.com:5432/production?sslmode=require

Supabaseโ€‹

postgresql://postgres:password@dbabcdefghijklmnop.supabase.co:5432/postgres?sslmode=require

Railwayโ€‹

postgresql://user:password@railway.railway.internal:5432/railway?sslmode=require

With SSL Verificationโ€‹

postgresql://user:pass@host:5432/db?sslmode=verify-full&sslrootcert=/path/to/ca.pem

With Application Nameโ€‹

postgresql://user:pass@host:5432/db?application_name=JetAdmin-Dashboard

With Search Pathโ€‹

postgresql://user:pass@host:5432/db?options=-c%20search_path%3Danalytics,public

Testing Connectionโ€‹

How to Testโ€‹

  1. Configure your PostgreSQL connection (details or string)
  2. Click "Test Connection" button
  3. Wait for connection attempt (1-5 seconds)
  4. Review the result

Test Resultsโ€‹

โœ… Successโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โœ“ Connection Successful! โ”‚
โ”‚ โ”‚
โ”‚ Connected to: postgresql://host:5432 โ”‚
โ”‚ Database: mydb โ”‚
โ”‚ User: myuser โ”‚
โ”‚ SSL: enabled (verify-full) โ”‚
โ”‚ Response Time: 45ms โ”‚
โ”‚ PostgreSQL Version: 14.5 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โŒ Failureโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โœ— Connection Failed โ”‚
โ”‚ โ”‚
โ”‚ Error: ECONNREFUSED โ”‚
โ”‚ Message: Connection refused โ”‚
โ”‚ Host: db.example.com:5432 โ”‚
โ”‚ โ”‚
โ”‚ Troubleshooting: โ”‚
โ”‚ โ€ข Check if PostgreSQL is running โ”‚
โ”‚ โ€ข Verify host and port โ”‚
โ”‚ โ€ข Check firewall rules โ”‚
โ”‚ โ€ข Ensure network connectivity โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Common Test Errorsโ€‹

ErrorCauseSolution
ECONNREFUSEDPostgreSQL not running or wrong portStart PostgreSQL, verify port
ETIMEDOUTNetwork unreachable or firewallCheck network, firewall rules
ER_ACCESS_DENIEDWrong username or passwordVerify credentials
FATAL: database does not existDatabase name incorrectCheck database exists
no pg_hba.conf entryHost not allowed in pg_hba.confUpdate pg_hba.conf
SSL requiredServer requires SSLEnable SSL mode
certificate verify failedInvalid SSL certificateUse verify-ca or verify-full

Troubleshootingโ€‹

Connection Issuesโ€‹

"Connection Refused"โ€‹

Symptoms:

  • Test connection fails immediately
  • Error: ECONNREFUSED

Solutions:

  1. Verify PostgreSQL is running:

    # Linux/Mac
    sudo systemctl status postgresql

    # Windows
    Get-Service -Name postgresql
  2. Check PostgreSQL is listening:

    netstat -an | grep 5432
  3. Verify host and port are correct

  4. Check firewall allows connections:

    # Linux
    sudo ufw allow 5432/tcp

    # AWS Security Group
    # Add inbound rule: TCP 5432 from Jet Admin IP

"Connection Timeout"โ€‹

Symptoms:

  • Test hangs for 30+ seconds
  • Error: ETIMEDOUT

Solutions:

  1. Check network connectivity:

    ping db.example.com
    telnet db.example.com 5432
  2. Verify DNS resolution:

    nslookup db.example.com
  3. Check for network proxies

  4. Increase connection timeout in advanced options

"Access Denied"โ€‹

Symptoms:

  • Connection established but authentication fails
  • Error: FATAL: password authentication failed

Solutions:

  1. Verify username and password are correct

  2. Check user exists in PostgreSQL:

    \du
  3. Verify user has CONNECT privilege:

    GRANT CONNECT ON DATABASE mydb TO myuser;
  4. Check pg_hba.conf allows your connection:

    # Allow from specific IP
    host mydb myuser 192.168.1.0/24 md5

    # Allow from any IP (not recommended for production)
    host mydb myuser 0.0.0.0/0 md5

SSL Issuesโ€‹

"SSL Required"โ€‹

Symptoms:

  • Error: FATAL: no pg_hba.conf entry for host, SSL off

Solutions:

  1. Enable SSL in connection configuration
  2. Set SSL mode to require or higher
  3. Update pg_hba.conf to require SSL:
    hostssl    mydb    myuser    0.0.0.0/0    md5

"Certificate Verification Failed"โ€‹

Solutions:

  1. For self-signed certificates, use sslmode=require (not verify-full)

  2. For production, install CA certificate:

    {
    "additionalOptions": {
    "sslrootcert": "/path/to/ca-cert.pem"
    }
    }
  3. Verify certificate chain is complete

Performance Issuesโ€‹

Slow Connectionsโ€‹

Solutions:

  1. Increase connection pool size in PostgreSQL:

    SHOW max_connections;
    -- Default: 100
    -- Increase if needed: ALTER SYSTEM SET max_connections = 200;
  2. Add connection pooling (PgBouncer)

  3. Use connection pooling in Jet Admin (coming soon)

  4. Optimize network latency


Examplesโ€‹

Example 1: Local Developmentโ€‹

{
"connectionOption": "connectionDetails",
"connectionDetails": {
"connectionName": "Local-Dev-Postgres",
"host": "localhost",
"port": 5432,
"database": "myapp_dev",
"user": "postgres",
"password": "password",
"sslMode": "disable"
}
}

Example 2: Heroku Productionโ€‹

{
"connectionOption": "connectionString",
"connectionString": "postgresql://username:password@ec2-54-123-45-67.compute-1.amazonaws.com:5432/dbname?sslmode=require"
}

Example 3: AWS RDS with SSLโ€‹

{
"connectionOption": "connectionDetails",
"connectionDetails": {
"connectionName": "AWS-RDS-Production",
"host": "mydb.123456789012.us-east-1.rds.amazonaws.com",
"port": 5432,
"database": "production",
"user": "jetadmin",
"password": "secure-password-here",
"sslMode": "verify-full",
"additionalOptions": {
"connectTimeout": 15,
"applicationName": "JetAdmin-Production"
}
}
}

Example 4: Supabaseโ€‹

{
"connectionOption": "connectionString",
"connectionString": "postgresql://postgres:password@dbabcdefghijklmnop.supabase.co:5432/postgres?sslmode=require&application_name=JetAdmin"
}

Example 5: Multiple Schemasโ€‹

{
"connectionOption": "connectionDetails",
"connectionDetails": {
"connectionName": "Analytics-DB",
"host": "analytics.internal",
"port": 5432,
"database": "analytics_prod",
"user": "analyst",
"password": "secure-pass",
"sslMode": "require",
"additionalOptions": {
"options": "-c search_path=analytics,public"
}
}
}

Next Stepsโ€‹