Why the error “Call to undefined function curl_init()” is coming on your site?

If you are getting into trouble with the error “Call to undefined function curl_init()“, do not worry. It is commonly caused by the cURL library that is not installed on your system or enabled on your web server. cURL is a PHP extension used to convey data to or from a remote server. By default, this extension can be disabled by many web hosts due to security reasons. So, how to deal with this issue. In today’s blog, we will give you a helpful solution to eliminate this error. Now, let’s check it out.

Call To Undefined Function Curl Init

How to resolve the error “Call to undefined function curl_init()”

In order to address this problem, you can follow the steps below:

Step 1: Install the cURL extension

If you are using Linux, let’s use the following terminal command:

sudo apt-get install php-curl

If you are using Windows, you need to download the cURL extension from Office website.

Then, you need to restart your website server to check your changes

To restart Apache, you can run the following command:

sudo service apache2 restart

To restart Nginx, run:

sudo service nginx restart

After restarting, you can check if cURL is working by running the command below:

curl google.com

If you see some HTML, which means that cURL is working properly.

After the cURL has been installed yet. If the error is not gone, the extension may be disabled in your php.ini file. Now, you need to check the cURL extension in this file to enable cURL on your system.

Step 2: Edit php.ini file

  • In Linux

Initially, you need to locate the php.ini file and edit it.

On Apache, php.ini is usually located in /etc/php/5.6/apache2/php.ini. You need to replace 5.6 with your own version. For example, php7.1, php 7.4

You need to edit:

sudo nano /etc/php/5.6/apache2/php.ini

After that, press CRL+W and search for cURL. Then, remove the ; mark from the beginning of the following line. You need to notice that this line will be different depending on your version of php.

;extension=curl

To save this file and exit, press CTRL + X, press Y and then press Enter.

You must restart your web server after changing php.ini

To restart Apache, let’s run the following command:

sudo service apache2 restart

And restart Nginx, you run:

sudo service nginx restart

Similarly, you also need to test with the command below:

curl google.com

If the result appears some HTML, this means that cURL is working.

  • In Windows

To edit php.ini file in windows, firstly you go to your php.ini file and search for cURL.

Then, remove the ; mark from the beginning of the following line:

;extension=curl

In case, you are using an older version of PHP, this line will look like below.

;extension=php_curl.dll

Once the file was saved, you have to restart your HTTP server software. Then check if the error is gone.

Final thoughts:Call to undefined function curl_init()

Anyway, every problem will have its own solution. Hopefully, we brought you a useful solution to assist you to address your trouble efficiently. In contrast, if these methods can not resolve your issue, let us know your error by leaving a comment below. We promise to support you as soon as possible. Besides, don’t forget to follow our website, since we will offer plenty of valuable error blogs next time. Last but not least, why don’t you visit our Free WordPress Themes to get a beautiful theme as you wish?

4/5 - (2 votes)
Lt Digital Team (Content &Amp; Marketing)
Latest posts by LT Digital Team (Content & Marketing) (see all)
Summer Sale Grab 50% Off for everything on today, don't miss it. Coupon code: SUMMER2024 Redeem Now
🎉 Black Friday & Cyber Monday sale! Grab 50% Off for everything on today, don't miss it. Coupon code: BFCM50 Redeem Now