diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 8f318a1..f3307f3 100644
*** a/src/interfaces/libpq/fe-connect.c
--- b/src/interfaces/libpq/fe-connect.c
*************** connectFailureMessage(PGconn *conn, int 
*** 960,968 ****
  	else
  #endif   /* HAVE_UNIX_SOCKETS */
  	{
  		appendPQExpBuffer(&conn->errorMessage,
  						  libpq_gettext("could not connect to server: %s\n"
! 					 "\tIs the server running on host \"%s\" and accepting\n"
  										"\tTCP/IP connections on port %s?\n"),
  						  SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
  						  conn->pghostaddr
--- 960,976 ----
  	else
  #endif   /* HAVE_UNIX_SOCKETS */
  	{
+ 		struct sockaddr_in *remote_addr = (struct sockaddr_in *) &conn->raddr.addr;
+ 		/* not thread safe */
+ 		char *remote_ip = inet_ntoa(remote_addr->sin_addr);
+ 		bool host_ip_match = strcmp(conn->pghost, remote_ip) == 0;
+ 		
+ 		fprintf(stderr, "pghost = %s\n", conn->pghost);
+ 		fprintf(stderr, "pghostaddr = %s\n", conn->pghostaddr);
+ 		
  		appendPQExpBuffer(&conn->errorMessage,
  						  libpq_gettext("could not connect to server: %s\n"
! 					 "\tIs the server running on host \"%s\" %s%s%sand accepting\n"
  										"\tTCP/IP connections on port %s?\n"),
  						  SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
  						  conn->pghostaddr
*************** connectFailureMessage(PGconn *conn, int 
*** 970,975 ****
--- 978,987 ----
  						  : (conn->pghost
  							 ? conn->pghost
  							 : "???"),
+ 						  /* display the IP address only if not already output */
+ 						  !host_ip_match ? "(" : "",
+ 						  !host_ip_match ? remote_ip : "",
+ 						  !host_ip_match ? ") " : "",
  						  conn->pgport);
  	}
  }
