If you run Jenkins in the cloud or locally, chances are good that you have it behind a reverse proxy, typicaly Nginx. Nginx is the goto for this sort of thing and the Jenkins docs have decent recommendation for setting it up.

If you want to connect to Jenkins remotely via the Jenkins CLI there are two settings you need to disable in your Nginx config:

proxy_request_buffering    off; # Required for HTTP CLI commands in Jenkins > 2.54
proxy_buffering            off; # Required for HTTP CLI commands in Jenkins > 2.54

The Jenkins docs recommend proxy_request_buffering but not proxy_buffering. I've found that CLI connections just won't work unless both are disabled. It's also worth noting that you should also set proxy_http_version 1.1 as well per the wiki example.