The problem could be a wrong sonar url.
We had this issue in bitbucket pipelines where we defined SONAR_HOST_URL as environmental variable. However, there was an empty space at the end of URL and this was causing the same problem.