TWITTER_PROXY environment variable.
Setup
Set theTWITTER_PROXY environment variable before running any command:
Supported Proxy Types
HTTP Proxy
HTTPS Proxy
SOCKS5 Proxy
Authenticated Proxy
Common Proxy Software
Clash
Clash typically runs on port7890:
V2Ray
V2Ray SOCKS5 typically runs on port1080:
SSH Tunnel
Create a SOCKS5 tunnel:Shadowsocks
Shadowsocks local client on port1080:
Persistent Configuration
Add to your shell profile for automatic proxy usage:Bash/Zsh
Add to~/.bashrc or ~/.zshrc:
Fish
Add to~/.config/fish/config.fish:
Testing Proxy Connection
Verify proxy connectivity before running commands:Using curl
Using twitter-cli
Proxy Best Practices
Recommended Proxy Types
- Residential proxies — Real user IPs, lowest ban risk
- Mobile proxies — Cellular IPs, good for high-volume usage
- Personal VPN — Consistent IP with normal usage patterns
- SSH tunnel to home — Safe if home IP has clean history
Avoid
- Public proxies — Often blacklisted
- Datacenter IPs — AWS, GCP, DigitalOcean easily detected
- Free VPNs — Shared by many users, high ban risk
- TOR exit nodes — Blocked by Twitter
Rate Limiting with Proxy
Proxies help avoid IP bans but don’t bypass account-level rate limits:Combine proxy with conservative
rateLimit config for maximum safety.Debugging Proxy Issues
Connection refused
Cause: Proxy not running or wrong port. Solution:Timeout errors
Cause: Proxy is slow or blocking Twitter domains. Solution:- Test proxy with
curl -x $TWITTER_PROXY https://x.com - Try different proxy server
- Increase timeout in proxy software
407 Proxy Authentication Required
Cause: Proxy requires credentials but none provided. Solution:Certificate errors
Cause: HTTPS proxy with self-signed certificate. Solution:- Use HTTP proxy instead:
http://nothttps:// - Or install proxy CA certificate
Environment Variable Priority
If bothTWITTER_PROXY and system proxy variables are set:
TWITTER_PROXY takes precedence over http_proxy and https_proxy.Proxy with Docker
When running in Docker, passTWITTER_PROXY as environment variable:
Disabling Proxy Temporarily
Unset the variable to disable proxy for one command:Security Considerations
Proxy Security Checklist
- Only use proxies you control or from trusted providers
- Avoid free public proxies — they may log/steal credentials
- Use SOCKS5 over HTTP when possible (less inspection)
- Rotate proxy IPs periodically
- Monitor proxy logs for suspicious activity
- Use HTTPS endpoints to encrypt data between proxy and Twitter
Advanced: Per-Command Proxy
Override proxy for specific commands:Proxy + Authentication
Combine proxy with browser cookie extraction:Troubleshooting Checklist
Check proxy format
Ensure correct format:
- HTTP:
http://host:port - SOCKS5:
socks5://host:port - No trailing slash
Next Steps
Authentication
Set up cookies and tokens
Config File
Configure rate limits and retries
