157

I am getting this error when I try to pod repo update and pod install

CDN: trunk URL couldn't be downloaded: https://cdn.cocoapods.org/deprecated_podspecs.txt, error: Failed to open TCP connection to cdn.cocoapods.org:443 (No route to host - connect(2) for "cdn.cocoapods.org" port 443)

Does somebody know how to fix this problem?

1
  • In case it helps someone, I had to disable my pi-hole and then it worked. :D
    – ihake
    Commented Nov 29, 2023 at 14:42

27 Answers 27

418

I got it working by using below commands:

  1. pod repo remove trunk
    and then

  2. pod install or pod update

8
  • 11
    removing the trunk fixed it for me.
    – Ants
    Commented Mar 17, 2020 at 22:16
  • 29
    Works for me too, except that I used pod update instead of pod install.
    – KoCMoHaBTa
    Commented Apr 13, 2020 at 10:14
  • 13
    It would be good, if you will explain what this command do and what can it affect to.
    – Nike Kov
    Commented Jul 29, 2020 at 15:00
  • pod install not works, but pod update works for me.
    – Kimi Chiu
    Commented Mar 18, 2021 at 6:17
  • Works for me only after restarting my PC. :/ Commented Apr 13, 2021 at 9:38
36

It seems that it's a cdn problem because when i use proxy the link https://cdn.cocoapods.org/all_pods_versions_e_2_1.txt is opened and when not it return error.

What i did: gem uninstall cocoapods gem cleanup rvm osx-ssl-certs update all

That didn't help.

Then i went to Chrome and opened https://cdn.cocoapods.org/all_pods_versions_e_2_1.txt it was an error. Then i cleared cache but it didn't help. After switching to proxy and returning back it started to work.

Resume: Turn on and switch off the VPN.

Also try to pod cache clean --all and pod setup by @NightWatcher

4
  • 4
    Getting this issue from Russia. Turning ON VPN helped me.
    – Woof
    Commented Feb 10, 2020 at 5:00
  • Voted up. You put me on the right track, disabling OpenDNS worked for me.
    – Romano
    Commented Mar 18, 2021 at 9:17
  • 3
    pod cache clean --all worked for me. thanks, @Nik Kov Commented Jun 8, 2021 at 4:39
  • It seems that that problem could be because of CDN errors: status.cocoapods.org/#month
    – Nike Kov
    Commented May 12, 2022 at 20:15
21

Step one. Remove trunk & master

pod repo remove trunk
pod repo remove master

Step two. Add source in podfile.

source 'https://github.com/CocoaPods/Specs.git'
source 'https://cdn.cocoapods.org/'

Step three. Run pod update. Solve my problem.

pod update --verbose
0
15

I fixed it by this solution Add this to your Podfile:

source 'https://cdn.cocoapods.org/'

Afterwards, run the following command to remove it from your managed repo list (in console):

pod repo remove master

Cheers!

3
  • 1
    Thanks for the answer, do you have any reference link for this? Commented Jan 16, 2020 at 8:59
  • 1
    Sorry I don't remember where I found this solution. Hope it helped you
    – Eugene
    Commented Jan 23, 2020 at 0:41
  • worked once. Then it doesn't work anymore
    – Gargo
    Commented Jul 1 at 6:56
11

I spend hours by uninstalling and reinstalling pods, Connecting and disconnecting wifi, and trying out different solutions I could find from the internet. And nothing worked. Finally I decided to restart my Macbook and the problem solved. So before trying the solutions given above, I would strongly recommend you to try restarting your system.

2
  • 1
    Same here: Cocoopads 1.10.0 failed to download a CDN dependency on the terminal. But I could open the file in a browser just fine. Reboot fixed it! Commented Nov 2, 2020 at 11:22
  • 2
    old school reboot saved me too
    – Qasim
    Commented Apr 13, 2021 at 8:06
10

Just try this in your terminal:

sudo gem install cocoapods
2
  • This solved my problem. I was using an older version that apparently had this bug. Commented Mar 19, 2020 at 12:49
  • 1
    SO answers require some sort of explanation as to what and why we should do the steps in your answer. This is so that people can learn and understand what they are doing. Also, it stops people from tricking others into using dangerous code, etc. Please explain you answer a little, or more. Commented Apr 30, 2021 at 10:32
8

After checking all the answers and using VPN just to update pods, I've tried:

pod repo remove trunk
pod repo remove master
sudo rm -rf ~/.cocoapods/repos
pod update

I'm not specifying this BTW:
source 'https://cdn.cocoapods.org/'

And all worked.

2
  • 1
    I was using this in CI/CD, so I first had to run the first three commands (with set +e), then freshly start the process with only the fourth one. It started downloading the pods. Commented Jul 12, 2021 at 6:41
  • 1
    deleting ~/.cocoapods/repos helped Commented Sep 28, 2021 at 8:30
6

For those, who faced with the following:

[!] CDN: trunk Repo update failed - 1 error(s): CDN: trunk URL couldn't be downloaded: https://...podspec.json Response: 429 429: Too Many Requests

You should remove Podfile.lock, Pod folder and reconnect to your VPN (if any) then run

pod install --repo-update

1
  • I had the same problem and your solution fixed that! Thanks! Commented Mar 18, 2021 at 9:57
6

I had the same issue. I followed below steps and it works.

I suggest to restart the system before following below instructions.

Delete Podfile.lock add source 'https://github.com/CocoaPods/Specs.git' line in Podfile

Then run below commands

pod repo remove trunk
sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod cache clean --all
sudo gem uninstall cocoapods
sudo gem install cocoapods
pod install or pod update
1
6

Someone might be checking on this in 2023 so here's what I did (in a React Native project)

$ cd ios/
$ pod repo remove trunk
$ pod deintegrate
$ pod cache clean --all
$ pod install
5

Based on this github comment: whenever cocoapods CDN not working due to DNS issues, try adding directly the url that cdn.cocoapods.org redirects to, as a source in the top level of your Podfile:

source 'https://cocoapods-cdn.netlify.app/'
3
  • 1
    This link is no longer a valid option. The url redirects to a blog post indicating that 'cdn.cocoapods.org' should be used. Commented May 3, 2021 at 12:12
  • @PhillHealey just tested the source url in a Podfile and seams to work fine. Also the link for the github comment seams to be correct. At which url you are referring to?
    – gcharita
    Commented May 3, 2021 at 12:55
  • 1
    If you go to 'cocoapods-cdn.netlify.app' in a browser it redirects. Commented May 3, 2021 at 13:03
5

Remove Podfile.lock and try re-installing the Pods again (pod install). This worked for me.

1
  • This is the right answer. Deintegrate your pods, delete Podfile.lock and everything started working.
    – tuttu47
    Commented Sep 29, 2021 at 12:16
4

On all of those comments; nothing worked for me So i found this and it worked perfectly for me :

pod cache clean --all

pod setup

3

just remove Pods folder and Podfile.lock

add

source 'https://github.com/CocoaPods/Specs.git'

to the top Podfile

then clean cache pod cache clean --all

finally update and install pod pod install --repo-update

2

I was experiencing this issue, when I used VPN every thing was fine!

1

Tried many solutions from here and there but what worked in my case is:

gem uninstall cocoapods 
gem cleanup
sudo gem install cocoapods -n /usr/local/bin

Hope it works for you!

1

Several of these solutions didn't work for me but it was successful with updating the pods once I disconnected from AnyConnect VPN.

1
  • I'm using Tunnelblick and it worked fine after I disconnected. Might be related to DNS issue we have here from time to time. I can open timeouted link in a browser just fine though. Commented May 4, 2021 at 13:40
1

This worked for me, on Apple Mac with M1:

gem uninstall cocoapods
arch -x86_64 brew install cocoapods
arch -x86_64 brew reinstall cocoapods
brew link --overwrite cocoapods
0

i have tried all above options but nothing fixed my issue. i just switched my internet connection to other service provider and then try pod install and trunk url issue was no more there. so try to switch internet connection if facing trunk url issue.

1
  • Not a solution. removing .cocoapods/ directory as stated by Paresh Mangukiya do works Commented Apr 29, 2022 at 10:42
0

Faced the same issue and tried all the answers suggested above. But, the real issue seemed to be with not being able to access the Git repo for Cocoapods: ‘error: cannot open .git/FETCH_HEAD: Permission denied

Executing sudo chown -R $USER: . at /Users/user_name/.cocoapods/repos/cocoapods fixed the issue

0

it's up to proxy servise you've to do is all first open up your proxy and set it up into your country or turn it off temporarely and clean your xcode build folder and try again pod install ro pod update I hope that'll work

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 14, 2023 at 18:41
0

If all the answers did not help, try these steps:

  1. Make sure you're in ios folder and list all available pod repos

    pod repo list

  2. Iterate over the list and delete all of them

    pod repo remove [repo_name]

  3. In any folder on your local machine, clone Cocoapods Github repo

    git clone "https://github.com/CocoaPods/Specs.git"

  4. At the top of your podfile, reference only this local repo

    source '/Users/hossamabdelnaser/Specs' # This depends on where you cloned the repo

  5. Make sure you're in ios folder and install pods

    pod install

Hope that helps

0

Managed to solve this problem by using Cloduflare's WARP which is a proxy server

Downloaded from here:

https://1.1.1.1/

0

If you stuck with this annoying error, here all the solutions in order.

1: Try update cocoapods

sudo gem install cocoapods

Then pod update / install.

2: Remove cocoapods cache

pod cache clean --all
pod setup

Then pod update / install.

3: Remove cocoapods cache

pod repo remove trunk
pod repo remove master

Add source in your podfile:

source 'https://github.com/CocoaPods/Specs.git'
source 'https://cdn.cocoapods.org/'

Then pod update / install.

4: Uninstall / reinstall Cocoapods

gem uninstall cocoapods
brew install cocoapods

Then pod update / install.

5: Try reboot Mac

The last chance... Then pod update / install.

1
  • 1
    Thanks, good comprehensive list. I had to get to nr. 4 to fix it for me!
    – Ovi Trif
    Commented Jul 8 at 15:09
0

If you use Charles Proxy - quit it and restart IDE

0

If you're reading this in 2024, this is how I solved this issue:

make clean
pod deintegrate
pod install --repo-update 
-1

Just ran pod install --repo-update, and everything worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.