Trouble connecting with nodejs

Yann,
I was running into this exact issue. Even had the same results when using the trivial code. I ended up finding that the problem was due to an import statement. We utilize index files to handle exporting our classes. The original code that didn’t work, referenced an index file that was one directory up from the code I was trying to execute. The code that worked, referenced the index file that was in the same directory as the code that I was trying to execute. For example:

├ src
│   |- repositories 
|      |-index.ts
|      |-test
|        |-index.ts
|        |-myClass.ts

When I used import { MyClass } from 'src/repositories'; I had the same problem as you with the connection failing. When I changed my import to be import { MyClass } from 'src/repositories/test I was able to get a connection and the code worked.

Hope this helps.