Learn how to solve this exception when trying to install dependencies of an old Symfony project that relies on the old version of Symfony Flex.

How to solve Symfony composer curl error 6: while downloading https://flex.symfony.com/versions.json: Could not resolve host: flex.symfony.com

After 2 years, I had to make some modifications to a very simple project I created with Symfony 4. At the time, Flex was introduced and I decided to use it on the project, everything went well until today. The problem with Flex now is that the old infrastructure of Flex shut down in May of 2022. So as of now, if you try to install the dependencies of a project that refereces an old version of Symfony Flex, the project will simply throw an error like the following one: error  while downloading https://flex.symfony.com/versions.json: Could not resolve host: flex.symfony.com. The following exception probably indicates you have misconfigured DNS resolver(s).

This happened after installing the dependencies as usual in my project using:

composer install

The solution for this problem is quite simple fortunately, even Fabien Potencier wrote a short article about how to upgrade the projects to the latest version of flex in this article. To solve this problem, first verify if the problem is cause because of the transition of Flex to a public Github repository running the following command after installing the dependencies:

composer show symfony/flex

If some of your projects uses flex, which is probably the case, it's very likely that the version of Flex is less than v1.17.1. If that's the case you can fix this issue by simply upgrading flex using the following command:

composer update symfony/flex --no-plugins --no-scripts

This should simply update some dependencies and you should be good to go. If you run composer show symfony/flex again, you will get an output similar to:

name     : symfony/flex
descrip. : Composer plugin for Symfony
keywords :
versions : * v1.19.3
type     : composer-plugin
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage :
source   : [git] https://github.com/symfony/flex.git ab0453b16029e131c112df1a76e59eb2a47e1f67
dist     : [zip] https://api.github.com/repos/symfony/flex/zipball/ab0453b16029e131c112df1a76e59eb2a47e1f67 ab0453b16029e131c112df1a76e59eb2a47e1f67
path     : 
names    : symfony/flex

support
issues : https://github.com/symfony/flex/issues
source : https://github.com/symfony/flex/tree/v1.19.3

autoload
psr-4
Symfony\Flex\ => src

requires
composer-plugin-api ^1.0|^2.0
php >=7.1

requires (dev)
composer/composer ^1.0.2|^2.0
symfony/dotenv ^4.4|^5.0|^6.0
symfony/filesystem ^4.4|^5.0|^6.0
symfony/phpunit-bridge ^4.4.12|^5.0|^6.0
symfony/process ^4.4|^5.0|^6.0

Happy coding ❤️!


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors