Accurate and prompt detection of security attacks in the Industrial Internet of Things (IIoT) is important to reduce security risks. Since a massive number of IoT devices are placed over the globe and the quantity gets increased, an effective security solution is necessary. A botnet is a computer network comprising numerous hosts executing on standalone software. In this view, this article develops a novel Glowworm Swarm Optimization Driven Gated Recurrent Unit Enabled Botnet Detection (GSOGRU-BD) model in IIoT Environment. The presented GSOGRU-BD model intends to effectually identify the presence of botnet attacks in the IIoT environment. To do so, the GSOGRU-BD model initially pre-processed the input data to get rid of missing values. In addition, the GSOGRU-BD model involves the GRU model for the effective recognition and classification of botnets. Besides, the GSO algorithm is used for optimal hyperparameter tuning of the GRU model. Comparative experimental validation of the GSOGRU-BD model is tested using a benchmark dataset and the results reported the better outcomes for the GSOGRU-BD model.