# Troubleshooting poetry HangupException

## Background

I am working on a python project that uses [poetry](https://python-poetry.org/) as the package manager. Everything has been working as expected, which is quite nice.

Recently however, I introduced a change to run some tests in the ci pipeline on github. This meant that I needed to install the dependencies on the [github runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners).

And that is where the problem began.

## What happened?

On pushing my changes to the branch, the unit-test job failed with the error:  

> HangupException
> 
> The remote server unexpectedly closed the connection.

And a few stacktraces later, another one:

> The following error occurred when trying to handle this error:
> 
> HangupException
> 
> Host key verification failed.

It was not obvious to me at first why this was error was being thrown, given that it was happening when trying to install a public package(python-dateutil).

After a bit of head-scratching and googling to no avail, I added the verbose output option to the poetry install command to get more info on the error. And it turned out the error was happening because I had a private repository as part of my dependencies, and poetry did not have the permission to clone it. The error message was a bit more helpful now:

```bash
  Failed to clone git@github.com:mekicha/custom-scripts.git, check your git configuration and permissions for this repository.
```

Oh, so it turned out that since I did not have ssh authentication enabled from the github runner, poetry was failing to fetch the repository. In my scenario, doing this was not the best option and so I opted for the solution below.

## How did you solve it?

This [discussion on poetry repository](https://github.com/orgs/python-poetry/discussions/3794) was the answer I was looking for. There are different solutions there, but the one that worked for me was this:

```bash
git config --global url."https://github.com/".insteadOf git@github.com:
```

This change is written to git's global configuration file(`~/.gitconfig`).

And voila, poetry install now works again as expected, and so are the tests.

I could not have hoped for a happier ending than this one.
