Cant set headers after they are sent using connect

How to resolve this problem.

Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (http.js:704:11)
at ServerResponse.res.setHeader (C:\nodejs\node_modules\connect\lib\patch.js:59:22)

Im using connect and mongoose. When I run my code by giving wrong input which is not present in database should send the error message but Im getting error cant set headers. Node version 0.10 Mongoose version 3.6.11

can you post the function you called. Obviously you have different calls to res.send or res.redirect (or something like that)

check in this function all you if statement to see if a response might be call twice.

post your code if you still need help

regards