How to Check If cURL is Enabled on Your Server

Have you ever needed to use the cURL extension in your PHP website or web application? In this post, I will show you how you can check whether or not cURL is installed and enabled on your server, before you even start coding your project.

cURL, also known as Client URL Library, is a PHP extension that's used in connecting to and communicating with other web servers for tasks such as exchanging information and data, executing user-based actions and similar remote activities that are done programmatically, without a manual user interaction. It is based on the libcurl library of PHP and it has a number of curl_ functions to control things such as cURL sessions, cURL handles, cURL share handles and cRUL transfers, and the CURLFile class that creates CURLFile objects.

libcurl, hence cURL extension, supports various server protocol types such as HTTP, HTTPS, FTP, Telnet, Gopher, File and some others. You can use cURL extention for tasks related to HTTP's POST and PUT requests, for FTP file transfers, HTML form uploads, proxies, cookies and user authentication.

cURL requires the libcurl library to be installed on your server in order to function. If cURL is not installed or enabled on your server, you can either contact your web hosting company support or visit this page on the official PHP manual to learn about the requirements and installation process for the cURL extension.

TIP: You can learn more about currently available PHP extensions and download them from the following page: PHP Extensions List

Now, let's see how to figure out if PHP's cURL extension is enabled on your server or not.

Is cURL Enabled on Your Server?

While working on a server on your hosting account or on your computer locally, you can do a couple of things to check if a PHP extension is 1) installed and 2) enabled. The first thing is a visual inspection of the files located in the PHP installation folder. While what you can see on a shared hosting may be limited, if you have full control over your server (e.g. virtual or dedicated server, or a local server), you can simply go to the PHP folder and see if the extension file exists.

In our case, you can go to the PHP folder and open the ext folder within it, which contains the extension files. If you see the php_curl.dll file inside the ext folder, that means cURL extension is installed. If it doesn't exist, you will need to install it (refer to the link I provided above).

The fact that an extension is installed on your PHP module does note necessarily mean that it is enabled. To check whether it is enabled or not, we can do two things.

1. Check if cURL is Enabled with phpinfo()

In the first method, we will use the much useful phpinfo() function, which provides a long list of detailed information about your PHP installation, including the loaded extensions. Simply create a new PHP file and put the following into it:


When you open this page (using the correct URL on your server) in a web browser, it will display all the information you may need about the PHP installation. Search for the curl section on the PHP info page (press Ctrl + F and type in "curl" to do the search it quicker). If you see enabled as the cURL support value, that means cURL extension is enabled on your server; otherwise, it is not enabled.

How to Check If cURL is Enabled on Your Server

2. Check if cURL is Enabled with extension_loaded()

Another nice way for checking whether a PHP extension is loaded or not is to use the extension_loaded() function. This function takes the extension name as parameter and returns true value if it is enabled, false value if it is not. It is used as follows:

echo extension_loaded("curl");

If the cURL extension is enabled, testing the above code will return 1, if not, it will return 0.

You can also do the following check in your code to handle the case where it is not enabled:

if (extension_loaded("curl")) {
  // cURL is loaded...
} else {
  // cURL is not loaded...

If you try to use the cURL extension without first making sure it is installed and enabled and try to connect and communicate with other servers, you will receive some errors, which will help you in identifying and solving the issue.

f t g+ in