A heat exchanger comprising: a header (50, 50a~h, 60) extending in a horizontal direction; and a plurality of heat transfer tubes (31, 31a~c) extending in a direction that crosses the horizontal direction in which the header extends, disposed side by side in a longitudinal direction of the header, and connected to the header, wherein the header includes a first space allowing a refrigerant to flow in a first direction along the longitudinal direction of the header, a second space allowing the refrigerant to flow in a second direction that is a direction along the longitudinal direction of the header and that is a direction opposite to the first direction, the second space provided so as to include a portion that is disposed side by side with the first space in the horizontal direction, a circulation member (53, 53a~c, 63) extending so as to separate the first space and the second space from each other while extending in the longitudinal direction of the header, a first communication port allowing the first space and the second space to communicate with each other in the header, a second communication port allowing the first space and the second space to communicate with each other in the header at a position in the second direction with respect to the first communication port, and an inflow port allowing the refrigerant to flow into the header, and wherein the first space and/or the second space is directly or indirectly connected to the heat transfer tubes wherein a tilt angle with respect to a vertical direction, which is a direction in which the plurality of heat transfer tubes extend, is less than or equal to 45 degrees. a header (50, 50a~h, 60) extending in a horizontal direction; and a plurality of heat transfer tubes (31, 31a~c) extending in a direction that crosses the horizontal direction in which the header extends, disposed side by side in a longitudinal direction of the header, and connected to the header, wherein the header includes a first space allowing a refrigerant to flow in a first direction along the longitudinal direction of the header, a second space allowing the refrigerant to flow in a second direction that is a direction along the longitudinal direction of the header and that is a direction opposite to the first direction, the second space provided so as to include a portion that is disposed side by side with the first space in the horizontal direction, a circulation member (53, 53a~c, 63) extending so as to separate the first space and the second space from each other while extending in the longitudinal direction of the header, a first communication port allowing the first space and the second space to communicate with each other in the header, a second communication port allowing the first space and the second space to communicate with each other in the header at a position in the second direction with respect to the first communication port, and an inflow port allowing the refrigerant to flow into the header, and wherein the first space and/or the second space is directly or indirectly connected to the heat transfer tubes wherein a tilt angle with respect to a vertical direction, which is a direction in which the plurality of heat transfer tubes extend, is less than or equal to 45 degrees. <EOS>