Today, the Internet is growing at a very high speed, on the one hand, it facilitates the daily life of people, but on the other hand, if the necessary security measures are not taken, it exposes the security of the network to possible threats. Today, to detect or prevent network attacks, many network intrusion detection systems (IDS) based on machine learning algorithms have been proposed to achieve better accuracy and speed. Recent research on intrusion and anomaly detection shows the widespread use of machine learning (ML) algorithms such as decision trees to classify malicious traffic. Meanwhile, the classification process can be done by analyzing and selecting the appropriate features, which ultimately reduces the rate of misclassification and increases accuracy. In this research, we present a feature selection method based on a meta-heuristic algorithm, in which the received dataset, which includes different sessions and their features, is first selected with an approach based on the multi-objective grasshopper optimization algorithm, and redundant features are removed. In the next step, neural networks are used to classify sessions into healthy and attack sets. The proposed method is evaluated on different datasets and compared with the most advanced existing feature selection methods. The results show that the proposed method performs better in terms of classification and error detection