Error : couldn't connect to server 127.0.0.1:27017, connection attempt failed : Socket Exception

Check your mongod.log for more errors
Cd to your dbpath dir if it exists no need to create first
The command i gave is to connect assuming your mongod is running with no acces control
Since you say your mongod runs on port 27017 please check step by step first whether you can connect without security parms enabled
Shutdown your mongod edit config file and comment the security params.Start mongod and try to connect issuing just mongo
If you can connect then add back tls and other params and investigate why it is not working