Skip to content

PostgreSQL

PostgreSQL is a powerful, open-source object-relational database system. Datablast connects to PostgreSQL servers using standard connection parameters. This guide covers how to gather and configure the required credentials for both self-hosted and cloud PostgreSQL instances.


ParameterDescriptionDefault
HostPostgreSQL server address (localhost, IP, or domain name)localhost
PortPostgreSQL server port number5432
DatabaseDatabase name you want to connect topostgres
SchemaSchema within the database (optional, defaults to ‘public’)public
UserPostgreSQL username with appropriate permissions-
PasswordPassword for the PostgreSQL user-
postgresql://user:password@host:port/database

Contact your DBA for:

  • Server hostname or IP address
  • Database name
  • Schema name (if using custom schemas)
  • Username and password
  • Port number (if different from 5432)
  • SSL requirements

Amazon RDS PostgreSQL:

  • Endpoint: mydb.abc123.us-east-1.rds.amazonaws.com
  • Port: 5432 (default) or custom
  • SSL connections available
  • Master username and password

Supabase:

  • Connection string provided in dashboard
  • Uses connection pooling by default
  • SSL/TLS required for connections
  • Direct and pooled connection options

Google Cloud SQL:

  • Instance connection name
  • Public or private IP options
  • Cloud SQL Proxy for secure connections
  • IAM database authentication available

Azure Database for PostgreSQL:

  • Server name: servername.postgres.database.azure.com
  • Username format: username@servername
  • SSL connection required

Heroku PostgreSQL:

  • DATABASE_URL environment variable
  • Color-coded database names
  • Connection limit based on plan

Terminal window
psql -h HOST -U USER -d DATABASE -p PORT
Terminal window
psql --host=HOST --username=USER --dbname=DATABASE --port=PORT

Local PostgreSQL:

Terminal window
psql -h localhost -U myuser -d mydatabase -p 5432

Remote PostgreSQL:

Terminal window
psql -h db.example.com -U appuser -d production_db -p 5432

With SSL:

Terminal window
psql "host=secure-db.com port=5432 dbname=mydb user=myuser sslmode=require"

Using Connection URI:

Terminal window
psql postgresql://user:password@host:port/database

💡 Security Tip: PostgreSQL will prompt for password when using -U option. Never include passwords in command history or scripts.


FieldExample ValueNotes
Connection NameProduction PostgreSQLFriendly name for the UI
Hostdb.mycompany.comServer address or IP
Port5432Usually 5432 for PostgreSQL
Databaseanalytics_dbDatabase name
SchemapublicSchema within database
Userdatablast_userPostgreSQL username
Password••••••••••••User password (hidden)
DescriptionMain analytics databaseOptional connection notes

SSL Mode:

  • disable - No SSL
  • require - SSL required
  • verify-ca - Verify CA certificate
  • verify-full - Full certificate verification

Connection Pooling:

  • Useful for high-traffic applications
  • PgBouncer integration
  • Connection limits per user

Create a dedicated PostgreSQL user for Datablast:

-- Create user
CREATE USER datablast WITH PASSWORD 'secure_password';
-- Grant database connection
GRANT CONNECT ON DATABASE analytics_db TO datablast;
-- Grant schema usage
GRANT USAGE ON SCHEMA public TO datablast;
-- Grant table access
GRANT SELECT ON ALL TABLES IN SCHEMA public TO datablast;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO datablast;
  • Use SSL/TLS: Enable encrypted connections for remote databases
  • Limit Host Access: Configure pg_hba.conf for specific IP addresses
  • Minimal Permissions: Grant only necessary database and table access
  • Strong Authentication: Use SCRAM-SHA-256 or certificate-based auth

PostgreSQL Configuration (postgresql.conf):

listen_addresses = 'localhost,10.0.0.0/8'
ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'

Host-Based Authentication (pg_hba.conf):

# TYPE DATABASE USER ADDRESS METHOD
host analytics datablast 10.0.0.0/8 scram-sha-256
hostssl all all 0.0.0.0/0 scram-sha-256

Avoid entering passwords repeatedly by creating a password file:

Linux/macOS (~/.pgpass):

host:port:database:user:password
db.example.com:5432:analytics_db:datablast_user:my_secure_password

Windows (%APPDATA%\postgresql\pgpass.conf):

host:port:database:user:password
db.example.com:5432:analytics_db:datablast_user:my_secure_password

Set Proper Permissions:

Terminal window
chmod 600 ~/.pgpass
Terminal window
export PGHOST=db.example.com
export PGPORT=5432
export PGDATABASE=analytics_db
export PGUSER=datablast_user
export PGPASSWORD=my_secure_password

  • Check PostgreSQL service: systemctl status postgresql
  • Verify port: netstat -tlnp | grep 5432
  • Test network connectivity: telnet host 5432
  • Check firewall rules: Ensure port 5432 is open
  • Verify credentials: Double-check username and password
  • Check pg_hba.conf: Ensure host-based authentication allows your connection
  • User exists: Confirm user exists in PostgreSQL
  • Database access: Verify user has CONNECT permission
  • SSL mode mismatch: Server requires SSL but client doesn’t use it
  • Certificate problems: Invalid or expired SSL certificates
  • Protocol versions: Ensure compatible TLS versions
  • Schema access: User needs USAGE permission on schema
  • Table access: User needs SELECT permission on tables
  • Database access: User needs CONNECT permission on database

Host: mydb.cluster-xyz.us-east-1.rds.amazonaws.com
Port: 5432
Database: postgres
SSL Mode: require
Host: db.your-project.supabase.co
Port: 5432
Database: postgres
SSL Mode: require
Host: 1.2.3.4 (Public IP)
Port: 5432
Database: postgres
SSL Mode: require
Host: myserver.postgres.database.azure.com
Port: 5432
User: username@myserver
SSL Mode: require
5432/dbname
# Use DATABASE_URL from Heroku config
heroku config:get DATABASE_URL

-- Show current connection limits
SELECT setting FROM pg_settings WHERE name = 'max_connections';
-- Show active connections
SELECT count(*) FROM pg_stat_activity;
-- Check connection pool status (if using PgBouncer)
SHOW POOLS;
-- Enable query logging for analysis
SET log_statement = 'all';
SET log_min_duration_statement = 1000;
-- Analyze slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 10;

Always use encrypted connections for production databases and implement proper user access controls with minimal required permissions.