DocumentationDatabase ServiceConnection Strings

Connection Strings

Learn how to connect your applications to VPN Enterprise databases

Get Your Connection String

Retrieve your database connection string using the CLI tool or web dashboard.

# Get connection string for your database
db-cli connection-string my-database

# Get connection string with specific format
db-cli connection-string my-database --format jdbc

# Export to environment file
db-cli connection-string my-database --format env > .env.database

Connection String Formats

PostgreSQL Connection Formats
Different connection string formats for PostgreSQL databases

standard Connection

ssl Connection

pool Connection

Database Drivers

Recommended Drivers for PostgreSQL
Official and community-supported database drivers

Node.js

^8.11.3

pg

Python

^2.9.7

psycopg2

Java

42.6.0

postgresql

C#

7.0.6

Npgsql

Go

^1.10.9

pq

Ruby

^1.5.4

pg

Implementation Examples

Node.js Configuration
Database configuration setup for Node.js
// .env file
DATABASE_URL=postgresql://username:password@host:5432/database

// app.js
require('dotenv').config();
const { Pool } = require('pg');

const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
  ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false
});

module.exports = pool;
Node.js Usage Example
Example of using the database connection in Node.js
const pool = require('./db');

async function getUsers() {
  try {
    const result = await pool.query('SELECT * FROM users');
    return result.rows;
  } catch (error) {
    console.error('Database query error:', error);
    throw error;
  }
}

Security Features

SSL/TLS Encryption

All connections encrypted in transit with TLS 1.3

Automatic SSL certificate management and renewal

Connection Pooling

Efficient connection reuse and automatic scaling

Built-in pgBouncer for PostgreSQL, ProxySQL for MySQL

IP Whitelisting

Restrict database access to specific IP addresses

Configure allowed IPs in database security settings

Authentication

Strong password policies and optional 2FA

SCRAM-SHA-256 for PostgreSQL, caching_sha2_password for MySQL

Connection Best Practices

Use Environment Variables

Never hardcode connection strings in your source code

Use .env files and process.env for Node.js applications

Enable SSL/TLS

Always use encrypted connections in production

Add ?sslmode=require to PostgreSQL connection strings

Connection Pooling

Reuse database connections for better performance

Configure pool size based on your application's concurrency needs

Error Handling

Implement proper error handling and retry logic

Use try-catch blocks and exponential backoff for retries

Monitoring

Monitor connection usage and query performance

Set up alerts for connection pool exhaustion and slow queries

Testing Your Connection

Connection Verification
Verify your database connection is working properly

Using CLI Tool

# Test database connection
db-cli test-connection my-database

# Test with verbose output
db-cli test-connection my-database --verbose

# Test connection and run sample query
db-cli test-connection my-database --query "SELECT 1"

Connection Health Check

# Check database health
db-cli health my-database

# Monitor connection metrics
db-cli metrics my-database --connections

# View connection pool status
db-cli pool-status my-database

Next Steps

With your database connected, learn about backup strategies, performance optimization, and scaling your infrastructure.