PostgreSQL
Connect your PostgreSQL databases to Memex for AI-powered data analysis.
What is PostgreSQL?
PostgreSQL is a powerful, open-source object-relational database system known for its reliability, feature robustness, and performance. It's used by organizations of all sizes for everything from small applications to large-scale data warehousing. Once connected, Memex can query your PostgreSQL databases, explore schemas, and help you analyze your data through natural conversation.
What You'll Need
Host
PostgreSQL server hostname or IP
postgres.example.com or 127.0.0.1
Port
PostgreSQL server port
5432 (default)
Database
Name of the database
myapp_production
Username
PostgreSQL username
app_user
Password
PostgreSQL password
Your secure password
Finding Your Credentials
For Cloud PostgreSQL Services
Amazon RDS for PostgreSQL:
Log in to the AWS Console and go to RDS
Select your PostgreSQL instance
Find the Endpoint (this is your host) and Port in the Connectivity section
Use the master username or a dedicated user you've created
Google Cloud SQL:
Go to the Cloud SQL instances page
Select your instance
Find the Public IP address or Private IP address for the host
Use credentials created through the Users section
Azure Database for PostgreSQL:
Go to your PostgreSQL server in the Azure Portal
Find the Server name in the Overview (this is your host)
Use credentials set up during server creation or additional users you've created
Heroku Postgres:
Go to your app's Resources tab
Click on Heroku Postgres
Go to Settings → Database Credentials → View Credentials
For Self-Hosted PostgreSQL
Contact your database administrator to obtain:
The server hostname or IP address
The port number (default is 5432)
The database name
A username and password with appropriate permissions
Connecting to Memex
Open the Memex Hub from the sidebar
Click on the Connectors tab
Find and click the PostgreSQL card
Enter your Host, Port, Database, Username, and Password
Give your connection a memorable name (e.g., "Production PostgreSQL")
Click Add Connection
Verifying Your Connection
Once connected, try asking Memex:
You should see a list of tables in your database.
Using Your Connection
Here are some examples of what you can ask:
Security Considerations
User Permissions
Create a dedicated read-only user for Memex:
Never use the postgres superuser account for application connections. Always create dedicated users with minimal required permissions.
SSL/TLS Connections
PostgreSQL supports SSL/TLS for encrypted connections:
Most cloud providers enable SSL by default
For self-hosted instances, configure SSL in
postgresql.confUse
sslmode=requireor stricter for production connections
Network Security
Configure
pg_hba.confto restrict which hosts can connectUse firewall rules to limit access to trusted IP addresses
For cloud databases, use private networking or VPC when possible
Consider using SSH tunnels for additional security
Troubleshooting
Connection Refused
Verify the hostname and port are correct
Check that PostgreSQL is running (
systemctl status postgresqlon Linux)Ensure PostgreSQL accepts remote connections (check
listen_addressesin postgresql.conf)Verify
pg_hba.confallows connections from your locationCheck firewall rules allow connections on port 5432
Authentication Failed
Double-check your username and password
Verify the authentication method in
pg_hba.confmatches your connection (e.g.,md5,scram-sha-256)Ensure the user exists and has a password set
Check if the user has CONNECT permission on the database
Database Does Not Exist
Verify the database name is spelled correctly (PostgreSQL database names are case-sensitive by default)
Ensure the database exists:
\lin psql lists all databasesCheck that the user has permission to connect to the database
SSL Connection Required
If the server requires SSL, ensure your connection is configured for SSL
For cloud databases, SSL is often required by default
Check the
sslmodeparameter in your connection settings
Learn More
Last updated
Was this helpful?