In the research of wireless sensor network, how to improve the positioning accuracy of nodes is the key problem. At this stage, some scholars combine swarm intelligence optimization algorithm with wireless sensor network, and have achieved good results. However, in wireless sensor network node localization, the combination of some optimization algorithms and node localization still has some problems, such as slow convergence speed and low localization accuracy. In this paper, we use whale optimization algorithm to optimize the formula of the relationship between received signal strength and signal transmission distance, and train the parameters A and n, so as to optimize the relationship between signal strength and signal transmission distance. Through simulation experiments, the whale optimization algorithm is compared with the particle swarm optimization algorithm. The whale optimization algorithm has certain competitiveness and practicability.