The internet is growing very fast today. On the one hand, it facilitates people's daily lives, but on the other hand, privacy is exposed to potential threats if the necessary security measures are not taken. To detect or prevent network attacks in this area, a network intrusion detection system (IDS) may be equipped with machine learning algorithms for better accuracy and speed. Recent research into intrusion detection and anomalies shows the widespread use of machine learning (ML) algorithms to detect malicious Internet traffic, from a neural network to learning a model to display a sequence of connections between computers on a network by analysis and selection. Uses appropriate features. Dense attacks are more accurately detected, which ultimately reduces erroneous classification rates and increases accuracy. To identify such attacks, a hybrid optimization approach using the hybrid optimization algorithm of the Harris Hawk Optimization (HHO) algorithm and the Dragonfly Optimization algorithm (DA) is proposed. The NSL-KDD dataset is used where input data is pre-processed to remove noise and lost data. After data preprocessing, low-rate attacks after data splitting are selected using an HHO-DA hybrid optimization algorithm. After selecting attributes, a neural network classifier (MLP) is used for the attack classification process. The proposed combined method achieves higher performance than the previous classification method in attack classification. So that the proposed method has been able to achieve 5.6%, 2.6%, 3.8% and 3.0% improvement compared to the basic method in the evaluated data set for Accuracy, Precision, recall and F-Measure criteria.