Connection Issues
Connection refused
Connection refused
Error Message:Causes:
- PostgreSQL is not running
- Wrong hostname or port
- PostgreSQL not listening on the specified interface
-
Verify PostgreSQL is running:
-
Check connection string:
-
Check PostgreSQL listen address:
-
Docker networking:
Authentication failed
Authentication failed
Error Message:Causes:
- Wrong username or password
- User doesn’t exist
pg_hba.confdoesn’t allow the connection
-
Verify credentials:
-
Check pg_hba.conf:
-
Create user if missing:
-
Special characters in password:
SSL/TLS errors
SSL/TLS errors
Error Message:orSolutions:
-
Disable SSL for local testing:
-
Enable SSL in PostgreSQL:
-
Trust server certificate:
-
Verify CA certificate:
-
Skip verification (not recommended for production):
Timeout errors
Timeout errors
Error Message:Causes:
- Database is slow to respond
- Collection timeout too short
- Heavy load on database
-
Increase collection timeout:
-
Increase connection timeout:
-
Check database performance:
-
Disable slow collectors:
Too many connections
Too many connections
Error Message:Causes:
- PostgreSQL connection limit reached
- Connections not being closed properly
- Too many concurrent scrapes
-
Increase PostgreSQL max_connections:
-
Lower collection timeout:
-
Check current connections:
-
Increase scrape interval in Prometheus:
Metrics Issues
No metrics returned
No metrics returned
Symptoms:
/metrics endpoint returns only exporter internal metricsSolutions:-
Check exporter logs:
-
Verify DATA_SOURCE_NAME:
-
Test connection manually:
-
Check if disable-default-metrics is set:
Missing specific metrics
Missing specific metrics
Symptoms: Some expected metrics are not presentCauses:
- Collector is disabled
- Insufficient permissions
- PostgreSQL version incompatibility
-
Check collector status:
-
Enable the collector:
-
Check permissions:
-
Install required extensions:
Collector failures
Collector failures
Symptoms: Common failures:
pg_scrape_collector_success is 0 for some collectorsCheck logs:-
pg_stat_statements: Extension not installed or loaded
-
replication: User lacks replication permissions
-
stat_user_tables: Permission denied on user tables
Metrics have wrong values
Metrics have wrong values
Symptoms: Metrics exist but show unexpected valuesTroubleshooting steps:
-
Query PostgreSQL directly:
-
Check metric labels:
-
Verify scrape timing:
-
Check for multiple exporters:
Permission Errors
Permission denied on pg_stat_*
Permission denied on pg_stat_*
Error Message:Solutions:
-
Grant pg_monitor role (PostgreSQL 10+):
-
Create security definer functions (PostgreSQL 9.x):
-
Verify role membership:
Cannot read password file
Cannot read password file
Error Message:Solutions:
-
Fix file permissions:
-
Docker container permissions:
-
Kubernetes volume permissions:
Multi-target Issues
Auth module not found
Auth module not found
Error Message:Solutions:
-
Check config file is loaded:
-
Verify config file syntax:
-
Check config reload status:
-
Validate YAML:
Target parameter missing
Target parameter missing
Error Message:Solution:Ensure Prometheus relabeling is correct:
Docker-Specific Issues
Container can't connect to host PostgreSQL
Container can't connect to host PostgreSQL
Solutions:
-
Use host networking:
-
Use host.docker.internal (Mac/Windows):
-
Use Docker network:
-
Use host IP (Linux):
Environment variables not working
Environment variables not working
Symptoms: Container ignores DATA_SOURCE_NAME or other env varsSolutions:
-
Check variable names:
-
Quote values properly:
-
Use env file:
Debugging Tips
Enable Debug Logging
- Connection attempts
- Collector execution
- Query durations
- Error details
Check Exporter Health
Test with psql
Always verify the connection string works with psql:Check PostgreSQL Logs
- Connection attempts from exporter
- Authentication failures
- Permission errors
- Query errors
Verify Collector Metrics
Getting Help
If you’re still experiencing issues:- Check existing issues: Search the GitHub issues
-
Gather information:
-
Create a minimal reproduction:
- Simplify configuration to the bare minimum
- Test with a fresh PostgreSQL instance if possible
- Document exact steps to reproduce
-
Open an issue with:
- Exporter version
- PostgreSQL version
- Operating system
- Configuration (redact passwords)
- Error messages
- Debug logs
Next Steps
Security Best Practices
Ensure your deployment is secure
Performance Tuning
Optimize collector performance