*** a/src/interfaces/libpq/fe-connect.c
--- b/src/interfaces/libpq/fe-connect.c
***************
*** 819,827 **** connectOptions2(PGconn *conn)
  	}
  
  	/*
! 	 * Allow unix socket specification in the host name
  	 */
! 	if (conn->pghost && is_absolute_path(conn->pghost))
  	{
  		if (conn->pgunixsocket)
  			free(conn->pgunixsocket);
--- 819,828 ----
  	}
  
  	/*
! 	 * Allow unix socket specification in the host name if hostaddr is not set
  	 */
! 	if ((conn->pghostaddr == NULL || conn->pghostaddr[0] == '\0') &&
! 		conn->pghost && is_absolute_path(conn->pghost))
  	{
  		if (conn->pgunixsocket)
  			free(conn->pgunixsocket);
***************
*** 5354,5370 **** PQhost(const PGconn *conn)
  		return NULL;
  	if (conn->pghost != NULL && conn->pghost[0] != '\0')
  		return conn->pghost;
! 	else
! 	{
  #ifdef HAVE_UNIX_SOCKETS
! 		if (conn->pgunixsocket != NULL && conn->pgunixsocket[0] != '\0')
! 			return conn->pgunixsocket;
! 		else
! 			return DEFAULT_PGSOCKET_DIR;
  #else
! 		return DefaultHost;
  #endif
- 	}
  }
  
  char *
--- 5355,5369 ----
  		return NULL;
  	if (conn->pghost != NULL && conn->pghost[0] != '\0')
  		return conn->pghost;
! 	if (conn->pghostaddr != NULL && conn->pghostaddr[0] != '\0')
! 		return conn->pghostaddr;
  #ifdef HAVE_UNIX_SOCKETS
! 	if (conn->pgunixsocket != NULL && conn->pgunixsocket[0] != '\0')
! 		return conn->pgunixsocket;
! 	return DEFAULT_PGSOCKET_DIR;
  #else
! 	return DefaultHost;
  #endif
  }
  
  char *
