Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

apt cannot find php8.1-curl on a newer Ubuntu

ErrorMissing php8.1-curl package

Short answer

php8.1-curl is listed for Ubuntu 22.04 (jammy) only. Ubuntu 24.04 (noble) carries PHP 8.3, so its curl extension is php8.3-curl, also reachable through the php-curl package. Install that. If your app truly needs 8.1, use a PPA that builds it for your release.

  • Applies to Ubuntu 24.04, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask apt which php-curl packages your release knows about, and which PHP version the system ships.

    lsb_release -ds
    apt-cache policy php-curl php8.1-curl php8.3-curl
  2. 2Match what you see, then jump to its fix

    1. 1apt-cache policy shows php-curl with a candidate version and php8.1-curl with none.Your Ubuntu release ships a different PHP versionFix
    2. 2composer.json or the host's setup pins PHP 8.1, and every php8.1-* package is missing.The app needs PHP 8.1 on a release that does not ship itFix
    3. 3add-apt-repository: command not found on a minimal server image.add-apt-repository is missing, so the PPA step fails firstFix

What does the error look like?

  • Missing php8.1-curl package
  • apt cannot find or install php8.1-curl on Ubuntu 24.04

Cause 1 of 3

Your Ubuntu release ships a different PHP version

1Check

Ubuntu's package search lists php8.1-curl for jammy (22.04) and jammy-updates, and not for noble (24.04). On noble the php-curl package is provided by php8.3-curl.

apt-cache policy php-curl php8.1-curl

2Fix

Install the extension that matches the PHP you actually run. If PHP itself is not installed yet, install the matching CLI at the same time.

sudo apt update
sudo apt install php8.3-cli php8.3-curl

3Verify

Confirm the extension is loaded in the CLI.

php -m | grep -i curl

Confirmed by packages.ubuntu.com

Did this fix it?

Cause 2 of 3

The app needs PHP 8.1 on a release that does not ship it

1Check

Look at the PHP constraint in composer.json and compare it with what the release offers.

grep -n '"php"' composer.json
apt-cache policy php8.1-cli

2Fix

Prefer upgrading the app to the PHP the release ships. If you must stay on 8.1, the ondrej/php PPA on Launchpad builds PHP packages for Ubuntu Noble and Jammy. Its page calls them unsupported packages from an untrusted PPA, so decide on that basis.

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1-cli php8.1-curl

3Verify

Check the installed version and the extension.

php8.1 -v
php8.1 -m | grep -i curl

Confirmed by launchpad.net

Did this fix it?

Cause 3 of 3

add-apt-repository is missing, so the PPA step fails first

1Check

The command comes from the software-properties-common package.

command -v add-apt-repository

2Fix

Install that package, then repeat the PPA step.

sudo apt install software-properties-common

3Verify

The command now resolves.

command -v add-apt-repository

Confirmed by manpages.ubuntu.com

Did this fix it?

How do I stop it coming back?

  • Install php-curl or the versioned package that matches php -v, instead of copying a package name from an old guide.
  • Pin the PHP version in composer.json to what your server release ships.
  • Keep a note of any PPA you add, so a release upgrade does not surprise you.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

nginx gives up waiting for the app and returns 504

upstream timed out (110: Connection timed out) while reading response header from upstream

nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.

5 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.