The paper presents the analysis of energy retrofitting, integration of renewable energy and activation of energy flexibility in a cluster of buildings in the surroundings of a port on the Mediterranean Sea in Southern Italy, with the aim of checking the potential for it to achieve the status of positive energy district (PED). The objective of this study is to improve the contemporaneity between local energy generation and energy demand and reduce CO2eq emissions by considering signals that reflect the environmental variability of the electricity grid, through flexibility solutions applied to the HVAC system. The proposed scenarios are based on the dynamic simulation of the district and analyze the effect of actions that activate the energy flexibility of buildings through advanced control strategies of the air conditioning system. The results show that the joint action of energy efficiency strategies, integration of solar energy and energy flexibility improves the environmental sustainability of the district and the balance of energy flows. Specifically, the activation of energy flexibility contributes to a 10% reduction in operational CO2eq emissions and increases in self-consumption of energy per year. The operational emissions of the district vary from the base value of 33.37 tons CO2eq/y to 19.52 tons CO2eq/y in the scenario based on the integration of solar energy systems and energy efficiency measures, and to 17.39 tons CO2eq/y when also the demand-side energy flexibility is activated.