MariaDB / Editorial solution guide

Diagnose socket, TCP and authentication failures

Separate endpoint reachability from account authentication before changing application connection settings. All diagnostics are read-only examples for an already authorized session.

About 3 min readContent reviewed

Read-only knowledge base ยท No public comments

Recognize the symptoms

A local command-line login works but the application fails, or changing localhost to 127.0.0.1 changes the error. ERROR 2002 (HY000), ERROR 2003 (HY000) and ERROR 1045 (28000) point to different stages; retain the complete actual message and operating-system suffix privately rather than treating them as one password problem.

Understand the likely causes

  • On Unix, localhost commonly selects a local socket while explicit TCP uses a host and port. Containers have separate filesystem and network namespaces. Authentication then depends on user@host matching, the selected plugin, connector support and transport requirements. A socket path mismatch is not repaired by granting more SQL privileges.

Classify the failed stage

Record the intended endpoint, protocol, port or socket path, client location and exact error. A missing socket file or refused TCP connection generally occurs before account authentication. Access denied indicates a server responded but rejected authentication or an access condition. Check existing deployment documentation and approved listener information before testing alternatives. Do not expose passwords in command lines, paste connection URLs into tickets or change root authentication to make an application login work.

Identify the server reached by a working session

An existing authorized training session can reveal server identity and configured endpoints. These queries do not establish a new connection and were not executed for this guide. @@hostname is the server-reported host, not proof of a particular network route. A socket path inside a database container need not exist in an application container. Use the evidence to correct the client endpoint through the normal deployment process rather than restarting services speculatively.

sql Illustrative SQL; expected results are reasoned, not measured.
SELECT VERSION(), @@hostname, @@port;
SHOW VARIABLES LIKE 'socket';
SHOW VARIABLES LIKE 'skip_networking';

Environment-dependent inspection only; no hostname, port or socket output is invented.

Compare authenticated identity and connection identity

CURRENT_USER() identifies the matched account used for privileges; USER() reports connection identity. A mismatch can be legitimate but should be understood. unix_socket authentication can use the operating-system identity for local socket access and does not automatically authorize TCP with the same username. Ask the authorized account owner to inspect plugin and host requirements through their established process; this guide supplies no account-changing SQL or wildcard-host grants.

sql Illustrative SQL; expected results are reasoned, not measured.
SELECT CURRENT_USER(), USER(), CURRENT_ROLE();
SHOW GRANTS;

Inspect grants privately. A granted role may still need activation before object access succeeds.

Match the remedy to the evidence

Correct a socket path only when the application shares that namespace and local socket access is intended. Correct host and port when TCP is intended, including container service naming. For an authentication rejection, verify the exact service account, host match, supported plugin and TLS policy; repair provisioning through a separate reviewed change if needed. A successful administrator socket session does not prove the application password, TCP reachability or application-role grants are correct.

Verify the fix

From the intended application environment, use the established connection check and confirm the expected server and CURRENT_USER() without printing credentials. Verify one permitted read and the required role context. Keep reachability, authentication and object authorization results separate so a later privilege failure is not mislabeled as the original connection failure.

Keep it from recurring

  • Store explicit protocol and endpoint settings, document container boundaries, rotate service credentials through the normal secret system and test the same connector used in production. Keep administrative and application accounts separate, with a reviewed plugin and host policy.

Official references