packagist.phpcomposer json could not be downloaded error in Laravel solution

I had encountered an issue on composer when I am installing a package
in Laravel via composer, then it just hangs or stops on the line:
Updating dependencies (including require-dev)

and is returning errors like:
The "[.....].json" file could not be downloaded
(HTTP 1.1 404 Not Found)

I had run composer clear-cache and composer diagnose to detect any issues but everything seems to be okay.

I had also used VPN and modify my iPv6 settings, turned off my firewall as some solutions online suggested but is seems it does not solve the issue.

The solution is to force the use of https with composer. Run this command first:

composer config -g repo.packagist composer

then run your composer update or composer require [package] and see if the installation now goes through succesfully.

Many thanks to chriskacerguis of forum 🙂