Dashboard is constantly reloading, sometimes with error "Connection lost, reconnecting"

For over a month I’ve been facing the same issue every day. After some time (usually every 5-10 minutes or so), Home Assistant shows a popup saying “Connection lost… reconnecting”.
Sometimes it also reloads the dashboard without showing the popup.

Other times it stays stuck displaying a blank page with an animated loading icon, with chrome showing “Waiting for available socket…”

After reloading the page, it reloads very slowly. It can take anywhere from 1 min up to 5 mins until the charts are reloaded (I use mini-graph-chart). During that time, the graphs aren’t displayed

I have the same problem with Chrome, Firefox and Opera.

I’m using Duckdns+nginx and I keep the HA page open in Chrome on a computer. I have also tried disabling “Automatically close connection” in my profile

HA is running on Rpi4 wired ethernet with a stable connection so it’s not the network dropping

How can I troubleshoot this issue? I have no idea what is causing it