How to fix E: Syntax error in apt.conf.d/proxy.conf in APT

APTBEGINNERMEDIUMUpdated Dec 29, 2025· 139 views

This error occurs when the apt proxy configuration file contains syntax errors, most commonly missing semicolons at the end of configuration lines. APT parses all files in /etc/apt/apt.conf.d/ strictly, so any malformed syntax will prevent package updates.

Quick fix

Fixes E: Syntax error in apt.conf.d/proxy.conf

cat /etc/apt/apt.conf.d/proxy.conf
  1. View the proxy.conf file to identify the syntax error
  2. Use correct proxy.conf syntax with semicolons
  3. Verify syntax is correct by testing apt update
  4. Fix proxy URL encoding if it contains special characters
apt — error
cat /etc/apt/apt.conf.d/proxy.conf
E: Syntax error in apt.conf.d/proxy.conf

What this error means

The "E: Syntax error in apt.conf.d/proxy.conf" error indicates that APT's configuration parser encountered invalid syntax in your proxy configuration file. APT is strict about configuration syntax and requires precise formatting according to its grammar rules. This error typically manifests when: - **Missing semicolons**: Configuration lines in proxy.conf must end with a semicolon. APT treats this as required punctuation, not optional. - **Incorrect proxy syntax format**: Using the wrong syntax pattern for proxy declarations. APT supports specific formats like `Acquire::http::Proxy "..."` or `Acquire { http::Proxy "..."; }`. - **Malformed proxy URLs**: Proxy URLs with spaces, unescaped special characters, or invalid format can cause parsing failures. - **Extra characters or junk at end of file**: Trailing whitespace, extra blank lines, or characters after the closing semicolon can confuse the parser. - **Mixed syntax formats**: Mixing different proxy declaration styles in the same file without proper syntax structure. The error message typically shows the exact line where parsing failed, making it easier to locate the problematic configuration.

Typical symptoms

  • apt update fails with 'E: Syntax error in apt.conf.d/proxy.conf'
  • apt-get install commands fail immediately with syntax error
  • Error message shows the specific line number where parsing failed
  • All apt operations fail, not just proxy-related ones
  • System cannot resolve packages even with network connectivity
  • CI/CD pipelines fail during apt package installation stage

Common causes

  1. Missing semicolon at the end of proxy configuration line
  2. Incorrect proxy syntax format (missing or extra characters)
  3. Trailing whitespace or extra characters at end of file
  4. Unescaped special characters in proxy URL
  5. Using block syntax without proper braces and semicolons
  6. Mixing different proxy declaration formats in same file
  7. Invalid proxy URL format with spaces or special characters
  8. Manually editing proxy.conf and introducing typos

How to fix "E: Syntax error in apt.conf.d/proxy.conf"

1View the proxy.conf file to identify the syntax error

First, examine the proxy.conf file to see its current contents:

bash
cat /etc/apt/apt.conf.d/proxy.conf

The error message usually indicates the line number with the problem. Look for:
- Lines missing semicolons at the end
- Mismatched quotes in proxy URLs
- Extra characters or incomplete syntax

2Use correct proxy.conf syntax with semicolons

APT requires strict syntax with semicolons at the end of each line. The correct format is:

For simple proxy (HTTP/HTTPS):

bash
sudo nano /etc/apt/apt.conf.d/proxy.conf

Enter this content (note the semicolon at the end):

bash
Acquire::http::Proxy "http://proxy-server:8080";
Acquire::https::Proxy "http://proxy-server:8080";
Acquire::ftp::Proxy "ftp://proxy-server:8080";

Save with Ctrl+O, Enter, Ctrl+X.

For proxy with authentication:

bash
Acquire::http::Proxy "http://username:password@proxy-server:8080";
Acquire::https::Proxy "http://username:password@proxy-server:8080";

Important: Each line MUST end with a semicolon. Missing semicolons are the most common cause of this error.

3Verify syntax is correct by testing apt update

After editing, test if apt can parse the configuration:

bash
sudo apt update

If you still get the syntax error, the file still has issues. If it succeeds, the syntax is correct.

Check for common mistakes in your file:

bash
# View the exact file contents with line numbers
cat -n /etc/apt/apt.conf.d/proxy.conf

Look for:
- Lines without semicolons at the end
- Extra spaces or characters after the closing semicolon
- Incomplete or malformed proxy URLs

4Fix proxy URL encoding if it contains special characters

If your proxy username or password contains special characters, they must be URL-encoded:

Characters that need encoding:
- @ → %40
- : → %3A
- / → %2F
- # → %23
- ? → %3F
- = → %3D
- Space → %20

Example with special characters:

bash
# Original credentials: user@domain:P@ssw0rd
# URL-encoded: user%40domain:P%40ssw0rd

echo 'Acquire::http::Proxy "http://user%40domain:P%40ssw0rd@proxy-server:8080";' | sudo tee /etc/apt/apt.conf.d/proxy.conf

You can use Python to encode:

bash
python3 -c "from urllib.parse import quote; print(quote('P@ssw0rd', safe=''))"
5Use block syntax as an alternative format

If line-by-line syntax is giving issues, try the block format instead:

bash
sudo tee /etc/apt/apt.conf.d/proxy.conf << EOF
Acquire {
  HTTP::Proxy "http://proxy-server:8080";
  HTTPS::Proxy "http://proxy-server:8080";
  FTP::Proxy "ftp://proxy-server:8080";
};
EOF

Key points for block syntax:
- Opening brace: {
- Each line inside must end with semicolon
- Closing brace must be followed by semicolon: };
- No semicolon after individual proxy lines in some contexts

Then test:

bash
sudo apt update
6Check for hidden characters or encoding issues

Sometimes the file contains invisible characters or wrong line endings that cause syntax errors:

bash
# View hidden characters
cat -A /etc/apt/apt.conf.d/proxy.conf

Look for:
- ^M at the end of lines (Windows line endings) - should be $ only
- Extra spaces or tabs
- Strange characters

Convert DOS line endings to Unix:

bash
sudo dos2unix /etc/apt/apt.conf.d/proxy.conf

Or using sed:

bash
sudo sed -i 's/\r$//' /etc/apt/apt.conf.d/proxy.conf

Recreate the file from scratch:
If the file is corrupted, delete and recreate it:

bash
sudo rm /etc/apt/apt.conf.d/proxy.conf
echo 'Acquire::http::Proxy "http://proxy-server:8080";' | sudo tee /etc/apt/apt.conf.d/proxy.conf
sudo apt update
7Validate the configuration file syntax with apt

APT provides a way to check configuration syntax before running update:

bash
# Check for syntax errors in all config files
apt-config shell | head

Or dump the entire parsed configuration:

bash
apt-config dump | grep -i proxy

If this succeeds, your configuration is valid. If it fails with a syntax error, the problem is still in your files.

Check individual files:

bash
# List all files in apt.conf.d
ls -la /etc/apt/apt.conf.d/

# Each file should be syntactically valid on its own
8Remove or disable the problematic file if unable to fix

If you cannot resolve the syntax issue, temporarily disable the proxy configuration:

bash
# Rename the file to disable it
sudo mv /etc/apt/apt.conf.d/proxy.conf /etc/apt/apt.conf.d/proxy.conf.disabled

# Test if apt works without proxy
sudo apt update

Then either:

Option 1: Use environment variables instead:

bash
# Set proxy environment variables
export http_proxy="http://proxy-server:8080"
export https_proxy="http://proxy-server:8080"
export ftp_proxy="ftp://proxy-server:8080"

sudo -E apt update

Option 2: Recreate the file with minimal syntax:

bash
# Create a simple, clean proxy.conf
sudo tee /etc/apt/apt.conf.d/99proxy << 'EOF'
Acquire::http::Proxy "http://proxy-server:8080";
Acquire::https::Proxy "http://proxy-server:8080";
EOF

sudo apt update

Once you confirm apt works, diagnose the original file to understand what went wrong.

Advanced notes

Understanding APT configuration parsing:

APT uses a strict configuration parser that requires proper syntax. Unlike some configuration formats that are lenient, APT will completely reject malformed configuration and prevent all package operations.

APT configuration grammar:
- Identifiers: Acquire, http, https, ftp, Proxy, etc.
- Operators: :: (scope resolution) and { } (blocks)
- Values: Strings in quotes
- Terminators: Semicolons required at end of statements

When APT loads config files:
1. APT reads all files in /etc/apt/apt.conf.d/ in alphabetical order
2. Files are parsed sequentially
3. If ANY file has a syntax error, parsing stops and apt fails
4. The error message usually indicates the filename and line number

Filename conventions in apt.conf.d:
APT processes files in order, so naming matters:
- 50unattended-upgrades - Numbered prefixes control order
- 01proxy - Lower numbers processed first
- 99custom - Higher numbers processed last

Proxy configuration scope resolution:
- Acquire::http::Proxy - Only for HTTP connections
- Acquire::https::Proxy - Only for HTTPS (highly recommended)
- Acquire::ftp::Proxy - Only for FTP repositories
- Acquire::socks::Proxy - SOCKS proxy support

Port configuration:
Always include the port in the proxy URL, even if it's the default:
- http://proxy-server:8080 - Explicit port
- http://proxy-server - May fail if default port differs

Authentication in proxy URLs:
Format: scheme://username:password@host:port/

Special characters in passwords MUST be URL-encoded. Do not include the trailing slash in proxy.conf entries.

Frequently asked questions

What does "E: Syntax error in apt.conf.d/proxy.conf" mean?
conf" error indicates that APT's configuration parser encountered invalid syntax in your proxy configuration file. APT is strict about configuration syntax and requires precise formatting according to its grammar rules. conf must end with a semicolon.
How do I fix "E: Syntax error in apt.conf.d/proxy.conf"?
This error occurs when the apt proxy configuration file contains syntax errors, most commonly missing semicolons at the end of configuration lines. APT parses all files in /etc/apt/apt.conf.d/ strictly, so any malformed syntax will prevent package updates.
What causes "E: Syntax error in apt.conf.d/proxy.conf"?
Missing semicolon at the end of proxy configuration line Incorrect proxy syntax format (missing or extra characters) Trailing whitespace or extra characters at end of file
Is the "E: Syntax error in apt.conf.d/proxy.conf" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading