apt cannot find php8.1-curl on a newer Ubuntu
Missing php8.1-curl packageShort 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.
Fix it fast
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-curl2Match what you see, then jump to its fix
- 1
apt-cache policy shows php-curl with a candidate version and php8.1-curl with none.Your Ubuntu release ships a different PHP versionFix - 2
composer.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
add-apt-repository: command not found on a minimal server image.add-apt-repository is missing, so the PPA step fails firstFix
- 1
What does the error look like?
Missing php8.1-curl packageapt 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-curl2Fix
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-curl3Verify
Confirm the extension is loaded in the CLI.
php -m | grep -i curlConfirmed by packages.ubuntu.com
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-cli2Fix
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-curl3Verify
Check the installed version and the extension.
php8.1 -v
php8.1 -m | grep -i curlConfirmed by launchpad.net
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-repository2Fix
Install that package, then repeat the PPA step.
sudo apt install software-properties-common3Verify
The command now resolves.
command -v add-apt-repositoryConfirmed by manpages.ubuntu.com
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
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Composer reports a different PHP version than php -v on Ubuntu
You are running 8.1.2.
Composer takes its PHP version from the interpreter that runs it, unless config.platform fakes one.
3 causes, each with a fixServers
docker-php-ext-install mbstring fails: oniguruma not found
The docker-php-ext-install step exits with a non-zero code
mbstring needs the Oniguruma library to build its regex functions, and the PHP build finds it through pkg-config.
3 causes, each with a fixServers
Laravel returns 500 Internal Server Error on Apache
/var/www/html/.htaccess: RewriteCond: bad flag delimiters
Apache and Laravel report different 500s.
5 causes, each with a fixServers
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 fixServers
nginx and PHP-FPM show File not found or Primary script unknown
File not found.
PHP-FPM received a script path it could not turn into a file.
4 causes, each with a fix