Here are a few fundamental troubleshooting steps that may help. Some of the information will be redundant but review everything to determine if there is something you may have overlooked.
If you don't get anywhere, you can use the following procedure to determine if the problem is internal or external to your Mac. Causes may involve your router, your ISP, the DNS Server(s) it uses, or certain user-configurable options.
- Shut down your Mac.
- Load macOS Recovery by holding ⌘ and r (two fingers) while you start your Mac with a third finger.
- At the macOS Utilities screen, release those two fingers.
- Choose Get Help Online.
- Safari will launch, but it will lack your bookmarks, favorites, history and other preferences.
Determine if the problem persists while using Safari in that mode. After that, restart your Mac normally, and reply with your observations.
Needless to say, if you are using, or have used at any time in the past, any non-Apple "anti-virus", "cleaning", or "Internet security" products including "banking security", anything at all in that broad category of utterly useless garbage, don't. A lot of things won't work if you do.