Abstract Coastal aquifers are one of the most important sources of water supply, and it is expected that the effects of climate change will be one of their threatening factors in the short or long term. The present study was conducted in the northern coasts of Iran (Amirabad, Babolsar) and the main goal was to investigate the behavior of saltwater advance in coastal aquifers considering the changes in the coastline due to the effects of climate change and aquifer characteristics. In order to simulate the flow of underground water and the advancement of salt water in the coastal aquifer of the Caspian Sea, MODFLOW MT3DMS and SEAWAT numerical models were used in the GMS10.6 software. The results show that there is a salinity increase of up to 60 ppt, which is much higher than the minimum seawater salinity of 2 ppt. According to the results, it is clear that in the studied area, contaminated water entered the underground aquifers, especially in the coastal erosion areas and during the seasons when the sea level changes and when the changes in the coastline increase.