cURL error 3 url malformed : How we fix it
Stuck with cURL error 3 URL malformed message on your website? We can help you.
The error usually occurs due to incorrect URL usage or version mismatch between cURL and the underlying application.
At Bobcares, we often get requests to fix cURL errors, as a part of our Server Management Services.
Today, let’s see how our Support Engineers fixed the cURL error 3: <url> malformed for our customers.
What is cURL error 3 URL malformed?
As we know, cURL is a tool used to transfer data between servers using network protocols. But improper usage of cURL in application often throws errors.
Users often approach us with cURL error 3 URL malformed. As the name specifies, the error shows up when the URL is improperly formatted. This can be either due to incorrect syntax or else due to a version mismatch between cURL and the application involved.
For instance, the error appears as
Next, we’ll go through a few cases where our Support Engineers fixed this error.
How we fixed the cURL error?
This cURL error occurs in different servers due to different reasons. So when customers approach, our Support Engineers will have a closer look at each case and fix it. Let’s see a few such cases here.
1. Error while using a Guzzle library
One of our customers was working with the guzzle library to make HTTP requests to an API. But it ended up in cURL error 3. So, we checked the code he used to make the HTTP request.
We saw a code to verify the HTTPS URL,
$client->get('/', ['verify' => true]);
Hence, we checked the API and client settings. And ensured that the secure URL works fine. This verification is an important security check. So we never recommend skipping this, instead, we specified the location of CA files in the server in the client settings.
We also found a mismatch between URL and URI. An identifier was specified for the parameter base_url instead of a locator. Hence it ended up in cURL error.
Hence, correcting the client setting fixed the error.
In general, when such problems arise we make sure that the URL is properly specified so that we can avoid errors.
2. Paystack Laravel package
Another customer had a package that integrated the Paystack payment gateway with the Laravel app. He was getting cURL error 3 URL malformed in the Laravel app.
Our Support Engineers checked the installation location of the package. In a Laravel project, we must install the dependencies or other packages inside the root project folder.
So we installed the package in the Laravel project folder and manually published the configuration file. Later, we checked whether the config folder had the paystack.php file in it. Only then the Laravel app can use the payment gateway without error.
After that, we cleared both the config cache and app cache in Laravel.
php artisan config:cache php artisan cache:clear
Hence it fixed the error.
3. Outdated WordPress
In this case, the customer had a WordPress site with a Wordfence plugin. But while running a malware scan, it ended with the error cURL error 3: <url> malformed.
When we checked, we found that the user had an outdated WordPress. The cURL process was not able to read the WordPress URL. The URL used ‘//’ which a new cURL version doesn’t support.
Hence we upgraded the WordPress and fixed the error.
[Still, having trouble with cURL error 3 URL malformed? – We’ll fix it for you.]
In short, cURL error 3 URL malformed occurs due to incorrect usage of URL or due to version mismatch between cURL and the underlying web application. Today, we also saw how our Support Engineers fixed this error.