Cannot connect to NODE.JS EXPRESS from LOCALHOST

Hello, i’m having a lot of issues with the connection from node to mongodb (in windows and endeavour os) but in compass mongo seems to work, idk what to do

Try instead of localhost in your uri

I already tried and

Is mongod up?
Any other program using the same port?
Could be firewall blocking your connection
Try with a different internet connection like mobile hotspot

i don’t think that it’s a firewall problem because when from the browser i go to localhost:27017 there is writing “It looks like you are trying to access MongoDB over HTTP on the native driver port.” and mongodb compass and mongosh work