A simple web application to test PostgreSQL database connectivity and detect firewall blocking.
- Interactive UI: Enter PostgreSQL credentials directly in the web interface
- TCP Socket Test: Checks if the PostgreSQL port is reachable
- PostgreSQL Authentication Test: Attempts to connect and authenticate with the database
- Real-time Status: Shows connection status with visual indicators
- Detailed Results: Displays test duration and error messages
- Build the Docker image:
docker build -t pg-firewall-test .- Run the container:
docker run -p 5000:5000 \
-e PG_HOST=pg-1e8c0fd-stan-dmitriev-test.h.aivencloud.com \
-e PG_PORT=19030 \
-e PG_USER=avnadmin \
-e PG_PASSWORD=your_password \
-e PG_DATABASE=defaultdb \
pg-firewall-test-
Open your browser and navigate to
http://localhost:5000 -
Enter your PostgreSQL credentials in the form and click "Test Connection"
PG_HOST: PostgreSQL host (default:pg-1e8c0fd-stan-dmitriev-test.h.aivencloud.com)PG_PORT: PostgreSQL port (default:19030)PG_DATABASE: Database name (default:defaultdb)PG_USER: Database user (default:avnadmin)PG_PASSWORD: Database password (required)
- Install dependencies:
pip install -r requirements.txt- Set environment variables (optional):
export PG_HOST=pg-1e8c0fd-stan-dmitriev-test.h.aivencloud.com
export PG_PORT=19030
export PG_USER=avnadmin
export PG_PASSWORD=your_password
export PG_DATABASE=defaultdb- Run the application:
python app.py- Open your browser and navigate to
http://localhost:5000
- ✅ Success: Connection successful
- 🚫 Blocked: Firewall is blocking the connection
⚠️ Partial: Port is reachable but PostgreSQL connection failed- ❌ Error: Connection test failed
The app provides a REST API endpoint:
GET /api/check: Returns JSON with connection test results
Example response:
{
"timestamp": "2026-01-29T12:00:00",
"host": "pg-1e8c0fd-stan-dmitriev-test.h.aivencloud.com",
"port": 19030,
"overall_status": "success",
"overall_message": "Connection successful",
"tests": [
{
"name": "TCP Socket Connection",
"status": "success",
"message": "Port 19030 is reachable",
"duration_ms": 45.2
},
{
"name": "PostgreSQL Authentication",
"status": "success",
"message": "Successfully connected to PostgreSQL...",
"duration_ms": 120.5
}
]
}