The error indicates that the AEM instance is not accessible for package installation. Please ensure you have an instance of AEM running locally on port 4502 and you have the corresponding port specified in pom.xml:
There might be many reasons for this behavior. Some of them might be:
AEM instance is not up and running.
AEM instance might be running on different port than the one configured in your pom.xml file. In that case, you can change your pom port parameter or run aem on the same port mentioned in your file or use a different profile where you can pass the port.
check the credentials configured in your pom file is the valid credentials of your running aem instance.
I have come across these types issues when I play around with port numbers and while build, i'm unable to clean the project. Please clean your project(mvn clean), delete the 'target' folders in your working directory and check the port number in your parent pom/xml. The port number should be the same in your pom.xml and localhost:4502. I believe this would resolve your issue.
@danilo-delfio Agree with all the above replies, the issue "Connection Refused" clearly points out that Maven was not able to establish connection to the AEM instance. Do check the port number mentioned in the main pom.xml file under