Hugging Face is the largest hub for AI models, datasets, and spaces. However, users from Russia, China, and several other countries regularly face blocks: the page fails to load, model downloads are interrupted, and the API returns a 403 error. If you are working with neural networks and need stable access to repositories, proxies quickly resolve this issue without complex configurations.
Why Hugging Face is Unavailable: Reasons for Blocks
Before setting up a proxy, it's important to understand why access issues arise. The reasons can vary, and this affects which solution will work for you.
Geo-blocking by the provider. In Russia, several internet providers block or slow down traffic to foreign resources at the request of regulators. Hugging Face periodically falls under such restrictionsâespecially its CDN servers, through which model files ranging from several gigabytes to hundreds of GB are transmitted.
Corporate firewalls. If you work at a company or university, network administrators may block access to external repositories. This is particularly relevant for government institutions and large corporations where security policies prohibit downloading files from unknown sources.
Restrictions from Hugging Face itself. In 2024, the platform introduced restrictions for several regions on downloading certain modelsâespecially those subject to U.S. export control. Models marked as "restricted" may require account verification or may be completely unavailable from certain IP addresses.
Connection instability and interruptions. Even if there is no formal block, routing traffic from Russia to Hugging Face servers in the U.S. and Europe can be so unstable that downloading a 20 GB model is constantly interrupted. Proxies with servers in the U.S. or Europe resolve this issueâtraffic flows through a stable channel.
Rate limiting by IP. Hugging Face limits the number of requests from a single IP address. If you are automatically downloading several models in a row or using scripts for bulk dataset downloads, the platform may temporarily block your IP. Proxy rotation resolves this issue.
Important: A VPN is not the same as a proxy. A VPN encrypts all device traffic and often slows down the connection. A proxy operates at the level of a specific application or script, which is more convenient for downloading large files and automation.
What Proxies Provide When Working with Hugging Face
A proxy server acts as an intermediary between your computer and Hugging Face servers. Instead of a direct connection (which may be blocked or unstable), the request goes through a proxy server located in a country with normal access.
Hereâs what this specifically provides in practice:
- Stable downloading of large files. Models like LLaMA 3, Mistral, Stable Diffusion range from 4 to 150+ GB. Through a proxy with a server in Europe or the U.S., downloads proceed without interruptions because the channel to Hugging Face is short and stable.
- Bypassing provider geo-blocks. Your provider only sees traffic to the proxy serverânot to Hugging Face. The block is bypassed automatically.
- IP rotation to bypass rate limiting. If you need to download many models or datasets in a row, proxy rotation allows you to avoid temporary IP blocks.
- Operation on servers without a GUI. Proxies are easily configured through environment variablesâthis is convenient for working on remote servers, in Docker containers, Jupyter notebooks, and CI/CD pipelines.
- Access to restricted models. Some models are only available from IPs of certain countries. A proxy with the required geolocation opens access to them.
Moreover, proxies do not require changes to your project codeâjust set the configurations in the system or environment once, and all tools (huggingface_hub, transformers, git-lfs) will start working through the proxy automatically.
Which Types of Proxies are Suitable for Downloading Models
Not all proxies are equally suitable for working with Hugging Face. Letâs discuss the main types and their applicability for this task.
| Proxy Type | Speed | Stability | For Hugging Face | When to Choose |
|---|---|---|---|---|
| Data Center (DC) | ⥠High | â High | â Excellent | Mass downloading of models, scripts, CI/CD |
| Residential | đ Medium | â High | â Good | Access to restricted models, bypassing checks |
| Mobile | đ Medium | â ď¸ Depends | â ď¸ Excessive | Not needed for this task |
| Free | â Low | â Low | â Not suitable | Not suitable for serious work anywhere |
For most tasks with Hugging Face, the optimal choice is data center proxies. They provide maximum download speed (important when downloading models of tens of GB), stable connections, and fixed IPs. For downloading a 30 GB model, the difference between a slow and fast proxy is the difference between 2 hours and 20 minutes.
Residential proxies are useful if you encounter Hugging Face blocking data center IPs (this happens for some restricted models). Residential IPs appear as regular home users and are less likely to raise suspicions with the platform's security systems.
Mobile proxies for downloading models are excessiveâthey are more expensive, and their advantages (high trust from platforms for mobile IPs) are not needed here. Hugging Face is not a social network with anti-spam protection, so regular DC or residential proxies are sufficient.
Setting Up Proxies for Browser Access
If you simply need to open the Hugging Face website, explore models, or download a file manually via the web interfaceâset up the proxy in your browser. This is the simplest option.
Option 1: Browser Extension (for one-time tasks)
Install the FoxyProxy extension (Firefox) or Proxy SwitchyOmega (Chrome/Edge). After installation:
- Open the extension settings
- Add a new proxy profile
- Specify the type: HTTP or SOCKS5
- Enter the server address (host) and port
- If the proxy requires authenticationâenter the username and password
- Save the profile and activate it
- Open huggingface.coâthe site should load
Option 2: System Proxy Settings (for Windows)
If you want the proxy to work for the entire computer (including the browser, Python scripts, and other applications):
- Open Settings â Network & Internet â Proxy
- Enable "Use a proxy server"
- Enter the address and port
- Add localhost and 127.0.0.1 to the exceptions field
- Save the settings
đĄ Tip: To download large models through the browser, use a download manager (e.g., Free Download Manager)âit supports resuming downloads after connection interruptions and works with system proxy settings.
Setting Up Proxies for CLI and Python Environments
Most Hugging Face users download models via the command line or Python scriptsâusing libraries huggingface_hub, transformers, or directly via git lfs. For all these tools, the proxy is configured through environment variables.
Step 1. Set Environment Variables
This is the most universal methodâmost Python libraries and system utilities automatically pick up these variables:
# For Linux / macOS (in terminal or ~/.bashrc / ~/.zshrc) export HTTP_PROXY="http://username:password@proxy-host:port" export HTTPS_PROXY="http://username:password@proxy-host:port" # For Windows (in PowerShell) $env:HTTP_PROXY = "http://username:password@proxy-host:port" $env:HTTPS_PROXY = "http://username:password@proxy-host:port" # For Windows (in CMD) set HTTP_PROXY=http://username:password@proxy-host:port set HTTPS_PROXY=http://username:password@proxy-host:port
Replace username:password@proxy-host:port with the actual details of your proxy. If the proxy does not require authenticationâsimply specify http://proxy-host:port.
Step 2. Download the Model via huggingface_hub
After setting the environment variables, standard commands work without changes:
# Download the model via CLI huggingface-cli download mistralai/Mistral-7B-v0.1 # Or via Python from huggingface_hub import snapshot_download snapshot_download(repo_id="mistralai/Mistral-7B-v0.1")
Step 3. Configure Proxy Directly in Python (if environment variables do not work)
In some casesâsuch as in Jupyter Notebook or when running through an IDEâenvironment variables may not be passed. In that case, configure the proxy explicitly in the code:
import os import requests from huggingface_hub import snapshot_download # Set the proxy via os.environ os.environ["HTTP_PROXY"] = "http://username:password@proxy-host:port" os.environ["HTTPS_PROXY"] = "http://username:password@proxy-host:port" # Now download the modelâthe proxy will be applied automatically snapshot_download(repo_id="meta-llama/Meta-Llama-3-8B")
Setting Up Proxy for git lfs
If you are cloning a repository via git (using the git clone method), you need to configure the proxy for git separately:
# Configure HTTP proxy for git git config --global http.proxy http://username:password@proxy-host:port git config --global https.proxy http://username:password@proxy-host:port # Clone the repository with the model git clone https://huggingface.co/mistralai/Mistral-7B-v0.1 # To remove the proxy after use git config --global --unset http.proxy git config --global --unset https.proxy
â ď¸ Important: git lfs (Large File Storage) uses a separate channel for downloading large files. If the HTTP_PROXY environment variables are set globallyâgit lfs will pick them up. If notâadd them to .lfsconfig in the root of the repository.
Using Proxies in Docker and Server Environments
Many ML engineers work with models in Docker containers or on remote servers (AWS, GCP, Hetzner, own servers). If the server is located in Russia or another country with limited access to Hugging Faceâa proxy needs to be configured at the container or system level.
Option 1: Passing Proxy to Docker via Environment Variables
When starting the container, pass the environment variables using the -e flag:
docker run -it \ -e HTTP_PROXY="http://username:password@proxy-host:port" \ -e HTTPS_PROXY="http://username:password@proxy-host:port" \ -e NO_PROXY="localhost,127.0.0.1" \ python:3.11 bash
Option 2: Proxy in Dockerfile
If the proxy is needed during the image build stage (for example, to download a model during docker build):
FROM python:3.11
# Set up proxy for building
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV HTTP_PROXY=$HTTP_PROXY
ENV HTTPS_PROXY=$HTTPS_PROXY
RUN pip install huggingface_hub transformers
# Download the model during the build
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('mistralai/Mistral-7B-v0.1')"
Start the build while passing the proxy:
docker build \ --build-arg HTTP_PROXY="http://username:password@proxy-host:port" \ --build-arg HTTPS_PROXY="http://username:password@proxy-host:port" \ -t my-ml-app .
Option 3: Setting Up Proxy at the Server Level (Ubuntu/Debian)
If you want the proxy to work for all users and processes on the serverâadd the settings to the system config:
# Add to /etc/environment HTTP_PROXY="http://username:password@proxy-host:port" HTTPS_PROXY="http://username:password@proxy-host:port" NO_PROXY="localhost,127.0.0.1,::1" # Apply the changes source /etc/environment
After this, all commandsâpip install, huggingface-cli download, wget, curlâwill automatically use the proxy.
For server tasks where download speed of large files is important, data center proxies are well-suitedâthey provide high bandwidth and stable connections, which is critical when downloading models weighing 20â100+ GB.
Checklist: How to Verify that the Proxy is Working Correctly
Before starting to download a heavy model, ensure that the proxy is configured correctly. Hereâs a quick verification checklist:
1. Check that the proxy is working at all
# Check via curlâit should return the proxy server's IP, not your real IP
curl -x http://username:password@proxy-host:port https://api.ipify.org
# Check via Python
import requests
proxies = {"http": "http://username:password@proxy-host:port",
"https": "http://username:password@proxy-host:port"}
r = requests.get("https://api.ipify.org", proxies=proxies)
print(r.text) # Should output the proxy's IP, not yours
2. Check Hugging Face availability through the proxy
curl -x http://username:password@proxy-host:port https://huggingface.co/api/models?limit=1 # Expected result: JSON with model data (status 200)
3. Check download speed
# Download a small test file and measure the speed curl -x http://username:password@proxy-host:port \ -o /dev/null \ --progress-bar \ "https://huggingface.co/bert-base-uncased/resolve/main/config.json"
â Checklist Before Downloading the Model:
- The proxy IP is displayed when checked via api.ipify.org
- The Hugging Face API returns status 200
- The download speed of the test file is > 5 MB/s (for comfortable operation)
- The HTTP_PROXY and HTTPS_PROXY variables are set in the required environment
- For gitâthe proxy settings are configured via git config
- For Dockerâthe variables are passed via -e or ARG
- NO_PROXY contains localhost and 127.0.0.1
Common Mistakes and How to Avoid Them
We have compiled the most common issues encountered when setting up proxies for Hugging Face and their solutions.
Error 1: SSL certificate verify failed
Some proxies (especially corporate ones) intercept HTTPS traffic and substitute the SSL certificate. Python libraries do not trust such certificates and throw an error.
Solution: Use quality proxies that do not intercept SSL. If this is a corporate proxyâadd the company's root certificate to trusted ones via the REQUESTS_CA_BUNDLE variable.
Error 2: Proxy works in the browser but not in Python
System proxy settings in Windows are not always passed to Python. The browser reads them, but Python does not.
Solution: Explicitly set the environment variables HTTP_PROXY and HTTPS_PROXY before running the script or add them at the beginning of the Python file via os.environ.
Error 3: Download starts but interrupts midway
A proxy with traffic limits or an unstable connection may interrupt the download of large files.
Solution: Use proxies without traffic limits. The huggingface_hub library supports resuming downloadsâif the download was interrupted, run the command again with the same path, and it will continue from where it left off.
Error 4: 407 Proxy Authentication Required
The proxy requires authentication, but it is not passed in the request.
Solution: Ensure that the username and password are correctly specified in the proxy URL: http://login:password@host:port. If the password contains special characters (@, #, %)âencode them using URL encoding.
Error 5: Proxy works, but Hugging Face is still unavailable
This means that the proxy server itself is located in a blocked region or has routing issues to Hugging Face.
Solution: Check the geolocation of the proxy server. To access Hugging Face, choose proxies with servers in the U.S., Germany, the Netherlands, or other European countries. Avoid proxies from Russia, China, Iranâthey may have the same restrictions.
Error 6: Environment variables do not persist after reboot
If you set the variables via export in the terminalâthey only work in the current session.
Solution: Add the lines export HTTP_PROXY=... to the ~/.bashrc or ~/.zshrc (Linux/macOS) or in Windows system environment variables through "System Properties".
Conclusion
Setting up a proxy for Hugging Face is a straightforward task that resolves several issues at once: bypassing geo-blocks, stable downloading of heavy models, bypassing rate limiting, and accessing restricted repositories. The key advantage of the approach through environment variables is versatility: set it up once, and all tools (huggingface_hub, transformers, git lfs, curl) will work through the proxy automatically.
For most tasksâdownloading models, working with scripts, server environmentsâthe optimal choice is data center proxies: they provide maximum speed and stability when downloading large files. If you need access to models with geolocation restrictions or the platform blocks data center IPsâconsider residential proxies with the required geolocation: they appear as regular home users and rarely trigger blocks.
The main rule when working with Hugging Face through a proxy is to choose a server in the U.S. or Western Europe, check the connection before downloading heavy models, and remember the NO_PROXY variable to ensure local traffic goes directly.