Endpoints
Test Connection
Verify PostgreSQL database credentials and connectivity
POST
Overview
Tests database connectivity with provided credentials. This endpoint validates that Poge can establish a connection to the PostgreSQL server and execute queries.Request
PostgreSQL server hostname or IP addressExample:
localhost, db.example.com, 192.168.1.100PostgreSQL server port numberDefault:
5432PostgreSQL username for authentication
PostgreSQL user passwordOptional for users without password authentication
Target database nameDefaults to
postgres if not specifiedSSL connection modeOptions:
disable, require, preferDefault: disableResponse
Success Response
Connection status (true for successful connections)
Human-readable success message
Error Response
Always
false for errorsError message describing the failure
Additional context about the error and resolution steps
PostgreSQL or system error code
Examples
Successful Connection
Connection Refused
Authentication Failed
Database Not Found
Missing Required Fields
Error Codes
The endpoint returns specific error codes from PostgreSQL and the system:| Code | Error | Description |
|---|---|---|
ECONNREFUSED | Connection refused | Server is not running or port is incorrect |
ENOTFOUND | Host not found | Invalid hostname or DNS resolution failed |
ECONNRESET | Connection reset | SSL configuration mismatch |
28P01 | Authentication failed | Invalid username or password |
3D000 | Database does not exist | Specified database not found |
28000 | Invalid authorization | User lacks database access permissions |
Implementation Details
From/app/api/test-connection/route.ts:15-30:
The endpoint creates a new client connection (not pooled) to test credentials without affecting the connection pool.
Use Cases
- Server Setup Form: Validate credentials before saving connection
- Health Checks: Verify database availability
- Connection Debugging: Identify connection issues with detailed errors