SummaryThe Internet of Things is considered to be an emerging trend since it facilitates more effective communication among smart devices. The IoT technology acts as a double‐edged sword that has multiple advantages, along with the advantages, the cyber threats in the network have increased proportionally which initiates the necessity for the manufacturers to provide in‐built security‐enabled physical devices. Therefore, for ensuring IoT security against cyber threats, this research proposed a novel innovative detection method relying on the hybridized ensemble classifier. The classifier is developed through the integration of the Hybrid Forage Optimization (HFO) with the ensembled classifier. The hybrid ensemble classifier is developed based on the hybridization of convolutional neural network (CNN) and long short‐term memory (LSTM) classifiers, which provides more efficiency. The proposed hybrid forage optimization is initiated by integrating the searching characteristics of the birds, and animals for their food, which aims at locating the optimal food source. Moreover, the add‐on advantage is regarding the ensemble classifier, which is empowered with CNN and LSTM networks that further boosts the classification performance. The analysis of the datasets, such as the NSL‐KDD and KDD Cup 1999 dataset reveals that the accuracy of the classifier is 96% and 94%., which outperforms the existing methods.