db-conexion-socket

Diagnose PostgreSQL socket versus TCP connection failures in Django migrations and tests.

Updated May 13, 2026
One-click install
npx skills add https://github.com/jcg-admin/kaupamex-api --skill db-conexion-socket-jcg-admin
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-conexion-socket
Source: https://github.com/jcg-admin/kaupamex-api/tree/main/.claude/skills/db-conexion-socket
Command: npx skills add https://github.com/jcg-admin/kaupamex-api --skill db-conexion-socket-jcg-admin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database connection failures in the kaupamex-api project often look like credential errors but are actually socket-versus-TCP misconfigurations, peer authentication mismatches, or missing CREATEDB role attributes. This Skill provides an executable gate that reveals which connection mode Django is actually using before you touch any code. ## Core Features & Use Cases - Executable Connection Gate: Runs a Django shell command that prints the real ENGINE, HOST, and PORT so you can tell a Unix socket connection (HOST starting with /) from TCP (127.0.0.1) before running migrations or pytest. - Peer Authentication Diagnosis: Explains why the same password works over TCP but fails over the socket on Debian, and how pg_hba.conf rule ordering fixes it. - CREATEDB and Cluster Operations: Covers the global CREATEDB role attribute needed for test database provisioning and how to start PostgreSQL via pg_ctlcluster on Debian. - Use Case: A pytest run fails with "FATAL: Peer authentication failed for user django_user". Run the gate first, confirm the socket path is active, then fix the pg_hba.conf rule ordering instead of changing passwords. ## Quick Start Ask the assistant to run the database connection gate and diagnose why my Django migration or pytest run is failing to connect to PostgreSQL.

Frequently Asked Questions about db-conexion-socket

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check if Django connects to PostgreSQL via Unix socket or TCP?▼

Print connection.settings_dict['HOST'] from a Django shell. In libpq, a HOST starting with / designates the socket directory (socket connection), while 127.0.0.1 means TCP. The gate command in this Skill outputs ENGINE, HOST, and PORT for the testing settings.

Why does PostgreSQL peer authentication fail for my Django user?▼

Debian's default pg_hba.conf assigns peer authentication to the local socket channel, so the OS username must match the database role. The same password that works over TCP fails over the socket. Add an explicit rule for the application role above the generic line, since pg_hba evaluates top-down.

Why does Django get permission denied when creating the test database?▼

CREATEDB is a global role attribute in PostgreSQL with no per-database predicate. The application role needs it granted explicitly to provision test databases, unlike MariaDB's wildcard GRANT syntax.

How do I start PostgreSQL on Debian when pg_ctl is not in PATH?▼

Debian manages PostgreSQL per cluster, not per process. Use pg_lsclusters to list clusters and sudo pg_ctlcluster 16 main start to start one. Check readiness with pg_isready. The initdb, pg_ctl, and postgres binaries are intentionally absent from PATH.

Does the psycopg driver use a unix_socket option like mysqlclient?▼

No. The OPTIONS['unix_socket'] key exists only in mysqlclient; with psycopg it always returns None. In libpq the socket is expressed through the HOST setting itself, so diagnostics must inspect HOST rather than an options key.