I am unable to set up tunnels for accessing my localhost from the internet

You should check the logs of the cloudflared tunnel, as it will tell you why there was a bad gateway error. Docs: Tunnel logs · Cloudflare Zero Trust docs

Off the screenshot, my guess is that it because you are using http://localhost:443. This means that cloudflared is going to want a certificate to match localhost which would have to be self-signed. You can try disabling the TLS verification or switching to http://localhost instead.