Node: cannot connect to mongodb

cannot connect to mongodb ready state is 2

tried updating version

copied code from previous project

If the port is undefined, then it may be a problem with being unable to connect to Port 3000. Is the port in use by another service? I’m not entirely sure why it’s listing the port as undefined otherwise. You could also try another port by defining PORT as another port number in your .env file.

Also, it looks a bit different on my code where you have “CONNECTION_STRING”. For mine, I have it going into the .env file with “process.env.CONNECTION_STRING”.

Regarding the readyState, 2 means “Connecting” and you can see more about it here.

now the port is 3000 but is still in connecting state