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

Is your mongod up and running on port 27017?
ps -ef|grep mongo or check from service status depending on your install method
Is it running as service or manually started from command line?