I have read a lot about this problem. However, I still could not find a solution. If it seems to you that the solution is trivial, it is not. According to the recommendations of some topics, I checked the versions of the server mods and client mods. All versions were the same (minecraft version and mod version). I thought there was some kind of mod that prevents logging into the server, and I decided to get rid of one mod at a time. It got to the point where I had to delete ALL the server mods. In the end, I came to the conclusion that even on a server that doesn't have a SINGLE mod, I can't log in.
P.S. Since I am a person who does not know English well, I ask you not to condemn for making mistakes in the text.
Thanks