134

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?

Nike Kov
  • 12,630
  • 8
  • 75
  • 122

21 Answers21

348

I got it working by using below commands:

  1. pod repo remove trunk
    and then

  2. pod install or pod update

ankitjaiswal
  • 3,800
  • 2
  • 12
  • 10
31

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

Nike Kov
  • 12,630
  • 8
  • 75
  • 122
20

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
Zgpeace
  • 3,927
  • 33
  • 31
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!

Tim
  • 1,877
  • 19
  • 27
Eugene
  • 221
  • 3
  • 6
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.

Naval Hasan
  • 1,226
  • 1
  • 13
  • 18
10

Just try this in your terminal:

sudo gem install cocoapods
Eduard
  • 191
  • 10
  • This solved my problem. I was using an older version that apparently had this bug. – Erich Flock Mar 19 '20 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. – Phill Healey Apr 30 '21 at 10:32
7

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.

SoftDesigner
  • 5,640
  • 3
  • 58
  • 47
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/'
gcharita
  • 7,729
  • 3
  • 20
  • 37
  • 1
    This link is no longer a valid option. The url redirects to a blog post indicating that 'https://cdn.cocoapods.org' should be used. – Phill Healey May 03 '21 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 May 03 '21 at 12:55
  • 1
    If you go to 'https://cocoapods-cdn.netlify.app/' in a browser it redirects. – Phill Healey May 03 '21 at 13:03
5

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

Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75
  • This is the right answer. Deintegrate your pods, delete Podfile.lock and everything started working. – tuttu47 Sep 29 '21 at 12:16
5

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

Aleksey Potapov
  • 3,683
  • 5
  • 42
  • 65
4

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
Nitish
  • 995
  • 7
  • 17
  • I am getting the same issue right now, and it is because CDN is down, you can check the status here https://status.cocoapods.org/#month – Sunil Bhosale May 11 '22 at 14:25
3

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

Dharman
  • 30,962
  • 25
  • 85
  • 135
Glymaxus
  • 29
  • 4
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!

ViruMax
  • 1,216
  • 3
  • 16
  • 41
1

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

Kate M
  • 478
  • 4
  • 17
  • 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. – Anton Plebanovich May 04 '21 at 13:40
1

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
Gene M
  • 348
  • 2
  • 12
1

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

Mo Hassan
  • 11
  • 3
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.

M. Waris
  • 11
  • 1
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

amishra
  • 951
  • 9
  • 12
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

  • 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](/help/how-to-answer). – Community Jan 14 '23 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

Hosam Abdelnaser
  • 127
  • 2
  • 11
0

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

Moataz Fouuad
  • 63
  • 1
  • 5