I get the Error:
err = new ServerSelectionError();
^
MongooseServerSelectionError: connect ECONNREFUSED **My Server IP/ PORT**
at _handleConnectionErrors (C:\Users\elias\source\repos\Website-Backend\node_modules\mongoose\lib\connection.js:791:11)
at NativeConnection.openUri (C:\Users\elias\source\repos\Website-Backend\node_modules\mongoose\lib\connection.js:766:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { '**My Domain/ PORT**' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
This makes no sense because I connect with Localhost through Port forwarding MongDB Compass uses the Same Connection String and works perfectly.
mongodb://Username:Password.@localhost:PORT/?authMechanism=DEFAULT
ssh -L **PORT**:localhost:**PORT** **User**@**IP**
I tried allready switching Ports etc. The only Sollution is to open the Port in the Firewall but that is not really practical and secure. I think Mongoose is logging in to then get the IP of the Source and than trying to connect with that IP for some reason?