The majority of daily networks and communications rely heavily on network security. Researchers in cybersecurity emphasize the necessity of developing effective intrusion detection systems (IDS) to safeguard networks. The importance of efficient IDS escalates as attackers devise new types of attacks and network volumes expand. Furthermore, IDS aims to ensure the integrity, confidentiality, and availability of data transmitted across networked systems by preventing unauthorized access. Following numerous studies utilizing machine learning (ML) to develop effective IDS, the focus has shifted towards deep learning (DL) techniques as artificial neural networks (ANNs) and DL systems have become prevalent. ANNs are capable of generating features autonomously, eliminating the need for manual intervention. This paper introduces an innovative adaptive recurrent neural network-based fox optimizer (ARNN-FOX) method. The primary objective of the ARNN-FOX system is to efficiently detect and classify network intrusions, thereby enhancing network security. Data normalization is conducted to scale the incoming data into a usable format. The gray level co-occurrence matrix (GLCM) method is proposed for selecting the optimal subset of features for the ARNN-FOX method. In the proposed approach, the fox algorithm (FOX) is utilized for the adjustment of hyperparameters in the ARNN model. The efficacy of the ARNN-FOX approach is assessed using benchmark datasets. Based on comparative results, the ARNN-FOX method demonstrates superior performance in parameters such as accuracy, specificity, sensitivity, F1 Score, recall value, and precision values over existing models. The proposed ARNN-FOX-based IDS model for the network security in terms of accuracy is 15.12%, 8.79%, 6.45%, and 4.21% better than RNN, CNN-LSTM, DASO-RNN, and ChCSO-LSTM, respectively. Similarly, with respect to specificity, the suggested ARNN-FOX-based IDS model for network security outperforms RNN, CNN-LSTM, DASO-RNN, and ChCSO-LSTM by 32.43%, 8.89%, 3.16%, and 2.08%, respectively.