Attack detection is the major issue in healthcare‐based wireless sensor networks (H‐WSNs). Due to their low processing speed, very low storage space, poor attack detection rate, longer deployment time, poor communication range, and reduced energy, H‐WSNs are subjected to difficult implementation and have their own limitations. To tackle these issues, we have presented a hybrid deep learning model using convolutional neural network and long short term memory (HDMCL) for attack detection in H‐WSN. This research is divided into three steps: preprocessing, dimensionality reduction, and classification (attack detection). At first, the raw input data (patient's health data) is preprocessed using the one‐hot encoding method. Next, the modified Huber independent component analysis based squirrel search algorithm (MHICA‐SSA) effectively reduces the data dimensionality in which the MHICA‐SSA is the amalgamation of both modified Huber independent component analysis and squirrel search algorithm. The novel algorithm designed overcomes the complexities associated with existing techniques such as the curse of dimensionality problem, improves the parameter interpretation, minimizes the time and storage space, minimizes space complexity, and enhances the attack detection accuracy of the convolutional neural network‐based long short‐term memory (CNN‐LSTM). After that, the deep learning CNN‐LSTM model is utilized for normal, black hole, and gray hole attack detection. The NS2.34 network simulator implements the proposed work thereby the proposed work efficiency is validated using different performance measures such as packet delivery ratio, false alarm rate, network lifetime, energy consumption, throughput, attack detection time, and rate. The proposed work performance is evaluated using different existing methods such as fish swarm optimization based particle swarm optimization, intelligent opportunistic routing algorithm, Jensen‐Shannon divergence‐based independent component analysis, and radio frequency identification based WSN. The throughput of the proposed work is increased up to 3.2 times and the network lifetime is increased up to 4 times when compared to the existing techniques.