diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 8dd1a59..f03e12e 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -196,6 +196,10 @@ static const internalPQconninfoOption PQconninfoOptions[] = {
 		"Database-Host", "", 40,
 	offsetof(struct pg_conn, pghost)},
 
+	{"unix_socket_directory", NULL, NULL, NULL,
+		"Socket Directory", "", 40,
+	offsetof(struct pg_conn, pgunixsocket)},
+
 	{"hostaddr", "PGHOSTADDR", NULL, NULL,
 		"Database-Host-IP-Address", "", 45,
 	offsetof(struct pg_conn, pghostaddr)},
@@ -5034,6 +5038,14 @@ conninfo_storeval(PQconninfoOption *connOptions,
 			value = "prefer";
 	}
 
+	/*
+	 * Can only be configured via host= externally.
+	 */
+	if (strcmp(keyword, "unix_socket_directory") == 0)
+	{
+		keyword = "host";
+	}
+
 	option = conninfo_find(connOptions, keyword);
 	if (option == NULL)
 	{
