Overview
This guide walks you through connecting TextQL to your PostgreSQL database. You’ll need connection credentials from your PostgreSQL account to complete the setup.Prerequisites
To connect TextQL with your PostgreSQL database, you will need:- Host URL and Port (default: 5432)
- Username and Password
- Database name (default: postgres)
- Schemas (optional, if you want to specify specific schemas)
Finding Your Connection Details
Connection String Format
Most PostgreSQL providers display the connection string in this format:Example Connection String Breakdown
- Host URL:
db.example.com - Port:
5432 - Username:
username - Password:
pass123 - Database:
mydb
Creating the Connector in TextQL
Step 1: Navigate to Connectors Page
- Go to the TextQL Connectors Page
- Click New Connector
Step 2: Select PostgreSQL
Select Postgres from the available connectors to open the configuration form.Step 3: Enter Connection Details
The form requires the following information:Step 4: Test and Create
- Click Test Connection to verify your credentials and network access
- Once the test succeeds, click Create Connector to save the connection
Authenticating with AWS Secrets Manager
Instead of storing a static password in TextQL, you can point the connector at an AWS Secrets Manager secret. TextQL fetches the credentials at connect time, so password rotations (including RDS-managed rotation) are picked up automatically.Setting Up Secrets Manager Authentication
- In the PostgreSQL connector form, set How should users authenticate? to AWS Secrets Manager
- Enter the Secret ARN of the secret holding your database credentials
- (Optional) Enter an IAM Role ARN for TextQL to assume when reading the secret, plus the External ID its trust policy requires
- RDS-style JSON with
usernameandpasswordkeys (the format AWS RDS uses for managed secrets), or - A plain-text password (set the username on the connector form instead)
Cross-Account Access with an IAM Role
When the secret lives in a different AWS account than your TextQL deployment, create an IAM role in the secret’s account and enter its ARN in the IAM Role ARN field. The role needs a permissions policy that allows reading the secret:kms:Decrypt on that key.
The role’s trust policy must allow TextQL’s service role to assume it. It must grant both sts:AssumeRole and sts:TagSession, in separate statements:
Principal.
Secrets Manager Troubleshooting
“not authorized to perform: sts:TagSession”- The trust policy of the role in the IAM Role ARN field grants
sts:AssumeRolebut notsts:TagSession. Add a separatests:TagSessionstatement as shown above. - The trust policy grants both actions in a single statement with an
sts:ExternalIdcondition. Split them into separate statements: the condition can never match forsts:TagSession, so the shared statement denies it. - If the trust policy is already correct, the TextQL service role’s own IAM policy may be missing
sts:TagSessionfor your role: for cross-account roles, both accounts must allow it. Ask your TextQL contact to verify.
- The trust policy’s
Principaldoes not match the TextQL service role, or the External ID in the form does not match the trust policy condition.
- The role’s permissions policy does not cover the secret ARN, or the secret’s resource policy denies access. If the secret uses a customer-managed KMS key, check
kms:Decryptas well.
- The secret value is JSON but has no
passwordkey. Use RDS-style{"username": ..., "password": ...}JSON or a plain-text password.
Connecting via SSH Tunnel
If your PostgreSQL database is in a private subnet and not directly reachable from the internet, you can connect through an SSH tunnel (also called a bastion host or jump server). TextQL will open an encrypted SSH connection to your bastion host and forward database traffic through it.When to Use an SSH Tunnel
- Your database is in a private VPC with no public endpoint
- Your security policy requires all external access to go through a bastion host
- You cannot or prefer not to whitelist TextQL’s IP addresses directly on the database
SSH Tunnel Prerequisites
In addition to your standard database credentials, you will need:Setting Up the SSH Tunnel
- In the PostgreSQL connector form, check Connect via SSH tunnel (bastion host)
- The SSH configuration fields will appear below the standard connection fields
- Enter your bastion host, port, username, and private key
- For Host URL and Port in the main connection fields, enter the database’s private address (the address reachable from the bastion host, not from the public internet)
How It Works
When TextQL connects to your database through an SSH tunnel:- TextQL establishes an encrypted SSH connection to your bastion host
- A secure tunnel is created from TextQL through the bastion to your database’s private address
- All database queries are forwarded through this tunnel
- The tunnel is torn down after the session ends
SSH Tunnel Troubleshooting
“Failed to establish SSH tunnel”- Verify the bastion host is reachable from the internet on the specified SSH port
- Confirm the SSH username and private key are correct
- Ensure the private key is in PEM format (starts with
-----BEGIN) - Check that the bastion’s security group allows inbound SSH from TextQL’s IPs (
44.229.62.69and54.69.138.147)
- The SSH tunnel connected, but the database is not reachable from the bastion. Verify:
- The database host and port are correct (use the private address)
- The bastion host has network access to the database
- Database security groups allow inbound connections from the bastion
- The SSH Host Public Key you provided does not match the bastion server’s actual host key. Retrieve the correct key from the bastion and update the connector.
Troubleshooting
Connection Fails
Verify the following:- Connection credentials are correct
- Host URL and port are accurate
- Database name is spelled correctly
- PostgreSQL server is running and accessible
Having trouble connecting? See the Network Configuration Guide for firewall and IP whitelisting setup.
Authentication Errors
Check:- Username and password are correct
- User has appropriate permissions
- Password doesn’t contain special characters that need escaping
Timeout Errors
Possible causes:- Firewall blocking connection
- Incorrect host URL or port
- Database server not responding
- Network connectivity issues
What’s Next
Once your PostgreSQL connector is set up, you can:- Ask Ana natural language questions about your data
- Generate SQL queries and visualizations
- Create reports and dashboards
- Share insights with your team