{"record":{"id":"5a0cc0a8f7b6d721","repo":"PaddlePaddle/PaddleOCR","slug":"downloading-from-failed-with-code","errorCode":null,"errorMessage":"Downloading from {} failed with code {}!","messagePattern":"Downloading from (.+?) failed with code (.+?)!","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"ppocr/utils/network.py","lineNumber":81,"sourceCode":"            retry_cnt += 1\n        else:\n            raise RuntimeError(\n                \"Download from {} failed. \" \"Retry limit reached\".format(url)\n            )\n\n        try:\n            req = requests.get(url, stream=True)\n        except Exception as e:  # requests.exceptions.ConnectionError\n            logger.info(\n                \"Downloading {} from {} failed {} times with exception {}\".format(\n                    fname, url, retry_cnt + 1, str(e)\n                )\n            )\n            time.sleep(1)\n            continue\n\n        if req.status_code != 200:\n            raise RuntimeError(\n                \"Downloading from {} failed with code \"\n                \"{}!\".format(url, req.status_code)\n            )\n\n        # For protecting download interrupted, download to\n        # tmp_file firstly, move tmp_file to save_path\n        # after download finished\n        tmp_file = save_path + \".tmp\"\n        total_size = req.headers.get(\"content-length\")\n        with open(tmp_file, \"wb\") as f:\n            if total_size:\n                with tqdm(total=(int(total_size) + 1023) // 1024) as pbar:\n                    for chunk in req.iter_content(chunk_size=1024):\n                        f.write(chunk)\n                        pbar.update(1)\n            else:\n                for chunk in req.iter_content(chunk_size=1024):\n                    if chunk:","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/utils/network.py#L63-L99","documentation":"RuntimeError from the same download helper when the HTTP request completes but returns a non-200 status code. Unlike connection failures (which are retried), any HTTP error status is fatal immediately: the server answered with 403/404/429/5xx and the download is aborted before any bytes are written.","triggerScenarios":"Auto-download of a model/dict file where the URL is wrong (404), the bucket requires auth or blocks hotlinks (403), rate limiting (429), or the remote server errors (5xx).","commonSituations":"Model URLs moved after a PaddleOCR release (old configs pointing at deleted buckets); mistyped custom pretrained_model paths; CDN throttling when many jobs start at once.","solutions":["Test the URL directly (curl -I <url>) and read the status: 404 means update PaddleOCR/config to the current model URL; 403/429 usually means throttling — wait and retry or use an alternate mirror.","Upgrade PaddleOCR to the version whose configs carry the corrected URLs.","Pre-download the file manually to save_path so the helper never issues the request."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import requests\n\ndef check_download_url(url) -> int:\n    r = requests.head(url, allow_redirects=True, timeout=10)\n    return r.status_code\n\nstatus = check_download_url(url)\nif status != 200:\n    raise SystemExit(f'{url} returned HTTP {status}; fix the URL/config or fetch the file manually into {save_path}')","typeGuard":null,"tryCatchPattern":"try:\n    download(url, save_path)\nexcept RuntimeError as e:\n    if 'failed with code 404' in str(e):\n        # permanent: the URL is gone — update PaddleOCR/config to the current release URL\n        raise\n    # 429/5xx are transient: back off and retry\n    time.sleep(30)\n    download(url, save_path)","preventionTips":["Keep PaddleOCR updated so model URLs point at live buckets.","Verify URLs with curl -I before large runs.","Mirror needed weights to your own object storage and point configs at the mirror."],"tags":["network","download","http-status","pretrained-model"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}