Fix: CocoaPods Trunk URL Couldn’t Be Downloaded – CDN Connection Error

Fix: CocoaPods Trunk URL Couldn't Be Downloaded – CDN Connection Error

Written by

in

Quick answer: Run pod repo remove trunk followed by pod install to reset the local trunk repository. If the issue persists, check your network connection, try toggling VPN/proxy, clear CocoaPods cache with pod cache clean --all, or verify CocoaPods service status at status.cocoapods.org.

Why this happens

The error CDN: trunk URL couldn't be downloaded appears when CocoaPods cannot reach its CDN (cdn.cocoapods.org) to fetch the latest podspec index. This typically stems from network routing issues — your machine cannot establish a TCP connection to the CDN on port 443. Common causes include temporary CDN outages, local firewall or proxy interference, VPN routing conflicts, or a corrupted local trunk repository cache.

The error message Failed to open TCP connection to cdn.cocoapods.org:443 (No route to host) indicates the request never reaches the server, which points to a network-layer problem rather than an authentication or permission issue.

How to fix it

1. Remove and re-add the trunk repository (most reliable fix)

The accepted solution is to delete the local copy of the trunk repo and let CocoaPods re-clone it on the next operation.

pod repo remove trunk
pod install

If you were running pod repo update, replace the second command with pod update. This forces a fresh clone of the spec repository from the CDN.

2. Clear CocoaPods cache and re-setup

Stale cache files can cause repeated failures even after removing the repo.

pod cache clean --all
pod setup

Then run pod install again.

3. Check network connectivity and VPN/proxy

Multiple users report that the CDN is reachable through a VPN or proxy but not on their direct connection. Test the CDN URL in a browser:

  • Open https://cdn.cocoapods.org/all_pods_versions_e_2_1.txt
  • If it loads via VPN but not without, toggle your VPN off and on, or switch proxy settings.

Corporate firewalls, DNS filtering, or ISP routing can also block the CDN. Try a different network (e.g., mobile hotspot) to isolate the issue.

4. Verify CocoaPods service status

Before spending time on local troubleshooting, check status.cocoapods.org for ongoing incidents. The CDN or spec repository may be experiencing downtime.

5. Nuclear option: clean project artifacts

If nothing else works, remove all generated files and start fresh:

rm -rf Pods/ Podfile.lock
pod install

This eliminates any chance of a corrupted Podfile.lock referencing unreachable sources.

How to prevent it

  • Keep CocoaPods updated: gem install cocoapods (or brew upgrade cocoapods if installed via Homebrew)
  • Run pod repo update periodically to keep the local spec cache fresh
  • Avoid committing Pods/ to version control; rely on Podfile.lock and pod install in CI
  • Monitor CocoaPods status page during widespread outages

FAQ

Why does pod repo remove trunk fix the issue?

It deletes the local mirror of the spec repository. The next pod install or pod update re-clones a fresh copy from the CDN, bypassing any corrupted index files or stale metadata that may be causing the download failure.

Is it safe to delete the trunk repo?

Yes. The trunk repo is a local cache of podspecs. CocoaPods rebuilds it automatically when needed. No project-specific data is lost.

What if the error returns after a few days?

Recurring failures usually indicate a persistent network problem — corporate firewall, DNS filtering, or ISP routing to the CDN. Consider configuring a reliable proxy or VPN for CocoaPods traffic, or mirror the spec repo internally if you manage a team.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.