Unable to connect with Mongoose to connection setup in 4.6

Péter Viszt shared this question 6 years ago
Answered

Hi!


I have a database which can be accessed using SSH, this part works fine. I right click on the connection to show the URI, and i try to use this to connect with my node.js app on localhost using mongoose, however its not working (ECONNREFUSED 127.0.0.1:27017 error).


I downgraded to 4.5 and this version works(i used it like this before for local development). Any idea whats wrong? Is it an issue with 4.6, or it was an issue with 4.5 that it worked like described? :)


Thanks

Replies (4)

photo
1

n version 4.6, the SSH connection did make some changes. In 4.5, ssh tunnel localport would use the server's remote port by default. To address this issue, in 4.6, we always use a random port (30000-66635), which is why 4.5 can connect to the server via localhost:27017, while 4.6 can't.

photo
1

Thanks! Is it possible to find that port somehow? Because the app always auto-updates to the newest version and i'm keep downgrading, theres no way to turn off updates :) And this feature was super handy for development.

photo
2

And, you can find the SSH local port from the tooltip of connection node, then you can connect to "mongodb://localhost:xxxxx" which will forward to the real port of your mongodb server. :)

/3d9c1d8774ba4360041df91a57ad7afb

photo
1

Awesome, thanks for the help!

Leave a Comment
 
Attach a file