Resolving Unable to connect to archive.ubuntu.com, 403 Forbidden Error in CircleCI

⚠️ Active Issue Alert, AskUbuntu  :  This article was created due to ubuntu reachability issue happening from 2025-06-10 until 2025-06-13. This article is currently displayed due to ongoing connectivity issues with Ubuntu's package repository infrastructure. These workarounds are temporary solutions while Ubuntu/Canonical addresses the underlying problems.

Overview

Ubuntu Repository Connectivity Issues - Temporary Workaround: Encountering the Unable to connect to archive.ubuntu.com connection timed out 403 Forbidden error during dependency installation via apt-get can disrupt your CircleCI workflows. This issue is typically due to connectivity problems with Ubuntu's package repository infrastructure not returning the healthy accessible endpoint.

Common Error Messages You Might See:

  • Could not connect to archive.ubuntu.com:80 , connection timed out
  • 403 Forbidden when accessing Ubuntu repositories
  • Unable to fetch some archives, maybe run apt-get update
  • Random build failures that succeed when retried

Solution: Choose Based on Your Error Type

To mitigate this issue, you can update your Dockerfile or build script to use alternative, reliable mirrors or url. This approach ensures that your builds can access the necessary packages without interruption.

For Connection and timeout Issues:

Replace the default Ubuntu repositories with reliable mirrors. You can use the following commands to update your Dockerfile or add the following to config's run step.

# Use AWS-based Ubuntu mirror for better connectivity
RUN sed -i 's|http://archive.ubuntu.com|http://us-east-1.ec2.archive.ubuntu.com|g' /etc/apt/sources.list
RUN sed -i 's|http://security.ubuntu.com|http://us-east-1.ec2.archive.ubuntu.com|g' /etc/apt/sources.list
# Or use Ubuntu's mirror protocol for automatic selection RUN sed -i 's|http://archive.ubuntu.com|http://mirrors.ubuntu.com/mirrors.txt|g' /etc/apt/sources.list RUN sed -i 's|http://security.ubuntu.com|http://mirrors.ubuntu.com/mirrors.txt|g' /etc/apt/sources.list
build:
docker:
- image: cimg/base:current
steps:
- checkout
- run:
name: Update Ubuntu package sources
command: |
# Modify system files
sudo sed -i 's|http://archive.ubuntu.com|http://us-east-1.ec2.archive.ubuntu.com|g' /etc/apt/sources.list
sudo sed -i 's|http://security.ubuntu.com|http://us-east-1.ec2.archive.ubuntu.com|g' /etc/apt/sources.list
# Update package lists with new sources
sudo apt-get update
  • http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ (AWS-based, good for CircleCI)
  • http://mirror.enzu.com/ubuntu/ (US-based)
  • http://mirror.mci-1.serverforge.org/ubuntu-ports/ (US-based)

For 403 Forbidden Issues:

If you're seeing 403 Forbidden errors, the issue is likely related to HTTP access restrictions. Recommendation from AskUbuntu Topic Switch to HTTPS:

# Replace HTTP with HTTPS for both repositories 
RUN sed -i 's|http://archive.ubuntu.com|https://archive.ubuntu.com|g' /etc/apt/sources.list
RUN sed -i 's|http://security.ubuntu.com|https://security.ubuntu.com|g' /etc/apt/sources.list
  • https://archive.ubuntu.com/ubuntu/ (Official HTTPS)
  • https://security.ubuntu.com/ubuntu/ (Official HTTPS)

Full list available at: Ubuntu Archive Mirrors

Additional Resources

Was this article helpful?
3 out of 5 found this helpful

Comments

0 comments

Article is closed for comments.