diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 579334af5c14a3195a2eae7ffcba297f504e71e0..ee31b48efdfc19100029f66b0927f9191815bcdb 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -862,7 +862,9 @@ static int parse_config(int reload)
 		dbport = atoi(s);
 	}
 
-	if (!ast_strlen_zero(dbhost) && !(s = ast_variable_retrieve(config, "general", "dbsock"))) {
+	if (!ast_strlen_zero(dbhost)) {
+		/* No socket needed */
+	} else if (!(s = ast_variable_retrieve(config, "general", "dbsock"))) {
 		ast_log(LOG_WARNING,
 				"PostgreSQL RealTime: No database socket found, using '/tmp/pgsql.sock' as default.\n");
 		strcpy(dbsock, "/tmp/pgsql.sock");