An unknown N1QL error occured. This is usually related to an out-of-memory condition

Hey @ittsrinadh,
Would you be able to try using cbq from your application server? It seems likely that there is a network issue between your application server and the Couchbase Server. You may also be able to use sdk-doctor to verify the connectivity (see: https://github.com/couchbaselabs/sdk-doctor/releases https://github.com/couchbaselabs/sdk-doctor/blob/master/README.md).
Cheers, Brett