There are some troubleshooting steps to follow, in no particular order:
Needless to say, if you are using any non-Apple "anti-virus", "cleaning", or "Internet security" products, anything at all in that broad category of utterly useless garbage, don't. A lot of things won't work if you do.
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.