Connection Options Overview
Zerops provides several ways to connect to PostgreSQL:- Internal connections - Between services in the same Zerops project (via private network)
- Remote connections:
- VPN access - From your local machine via Zerops VPN
- Direct IP access - Enables external applications to connect using TLS encryption by opening public ports on IPv6 (available by default) or IPv4 (requires add-on activation if not already enabled)
Connection Details
You’ll find PostgreSQL connection details in the service detail page under the Peek access details button (shows hostname, port, user, password, and connection string). The full list of connection-related environment variables is available in the service detail under Environment variables.Connection Parameters
| Parameter | Internal | External (TLS) | Env Variable |
|---|---|---|---|
| Hostname | Service hostname | Public IP address | hostname |
| Port (primary) | 5432 | 6432 (via pgBouncer) | port / portTls |
| Port (replicas, HA only) | 5433 | N/A | portReplicas |
| User | Identical to hostname | Same as internal | user |
| Password | Generated at creation | Same as internal | password |
| Connection string (primary) | postgresql://${user}:${password}@${hostname}:5432/${dbName} | Same format with TLS port | connectionString / connectionTlsString |
| Connection string (replicas, HA only) | postgresql://${user}:${password}@${hostname}:5433/${dbName} | N/A | connectionStringReplicas |
| Database name | db | Same as internal | dbName |
For more information about default PostgreSQL setup, users, and databases, see Manage PostgreSQL Users and Databases.
Connect from Services in the Same Project
All services within a Zerops project share a dedicated private network. There are two ways to implement connections between services in the same project:Method 1: Direct Connection Parameters
You can directly use the connection parameters from Peek Access Details:5433 instead of 5432 with the same credentials.
Method 2: Environment Variables (Recommended)
For better maintainability, Zerops creates environment variables for each PostgreSQL service that you can use in your application configuration. List of service environment variables is available in Zerops GUI. Go to a PostgreSQL service detail and choose Environment variables. To use variables from one service in another, prefix the variable name with the service hostname and underscore - to access theconnectionString variable of postgresql1, use postgresql1_connectionString.
For read-only connections (HA mode only), use the connectionStringReplicas variable instead.
Connect Remotely
Zerops offers two methods for connecting to your PostgreSQL database from outside the Zerops environment:Method 1: Connect via Zerops VPN
You can securely connect to PostgreSQL from your local workstation via Zerops VPN:Install & set up zCLI
Install and configure zCLI if you haven’t already.
Start the Zerops VPN
Start the VPN connection to your project.
Get connection details
Use the connection details from Access Details in the PostgreSQL service detail in Zerops GUI.
Stop the VPN when finished
Stop the Zerops VPN when you’re done.
Method 2: Connect via Direct IP Access
Direct IP Access uses pgBouncer for connection pooling and TLS termination. Internally, port5432 is available without SSL (and port 5433 for reads in HA mode). Externally, connections are secured with TLS through pgBouncer (port 6432) before being routed to your PostgreSQL service. The read replica port is not available for external connections.
Enable external access
Navigate to Public Access settings
Navigate to your PostgreSQL service in the Zerops GUI and choose the Public Access through IP Addresses section.
Choose IP version
Choose either IPv6 (available by default) or IPv4 (requires the unique IPv4 add-on).
Configure ports
Open one or more ports and point them to your PostgreSQL service (the system will direct them through pgBouncer):
- Choose any port from 10-65435 (except 80 and 443)
- Select destination service and internal port
- Each public port can be mapped to any internal service port
- Multiple public ports can point to the same internal port if needed
- Port configurations can be set independently for IPv4 and IPv6
Connection Examples
Using psql Command Line
Using Connection String
Next Steps
Manage Users & Databases
Create and manage users, databases, and plugins
Backup & Restore
Configure backups and restore your data