Ship detection faces significant challenges such as dense arrangements, varying dimensions, and interference from the sea surface background. Existing ship detection methods often fail to accurately identify ships in these complex marine environments. This paper presents OptiShipNet, an efficient network for detecting ships in complex marine environments using optical remote sensing images. First, to effectively capture ship features from complex environments, we designed a DFC-ConvNeXt module as the network’s backbone, where decoupled fully connected (DFC) attention captures long-distance information in both vertical and horizontal directions, thereby enhancing its expressive capabilities. Moreover, a simple, parameter-free attention module (SimAM) is integrated into the network’s neck to enhance focus on ships within challenging backgrounds. To achieve precise ship localization, we employ WIoU loss, enhancing the ship positioning accuracy in complex environments. Acknowledging the lack of suitable datasets for intricate backgrounds, we construct the HRSC-CB dataset, featuring high-resolution optical remote sensing images. This dataset contains 3786 images, each measuring 1000 × 600 pixels. Experiments demonstrate that the proposed model accurately detects ships under complex scenes, achieving an average precision (AP) of 94.1%, a 3.2% improvement over YOLOv5. Furthermore, the model’s frame per second (FPS) rate reaches 80.35, compared to 67.84 for YOLOv5, thus verifying the approach’s effectiveness.