Zookeeper & Kafka error KeeperErrorCode=NodeExists

I have written a kafka consumer and producer that worked fine until today. This morning, when I started zookeeper and kafka, my consumer was not able to read messages, and I found this in the zookeeper logs:

INFO Got user-level KeeperException when processing sessionid:0x151c41e62e10000 
     type:create cxid:0x2a zxid:0x1e txntype:-1 reqpath:n/a 
     Error Path:/brokers/ids 
     Error:KeeperErrorCode = NodeExists for /brokers/ids   

Look for log.dirs in your server.properties file and delete all the Kafka and zookeeper logs from there and try restarting zookeeper and Kafka respectively. I was facing the same issue and doing this resolved it.