cURL overview

cURL is free software that allows you to transfer between servers. The cURL project offers two sub-projects:

  • curl — This is the command line tool you can run on your local computer, or your DreamHost server. It offers several command options for you to send and receive data. 'curl' uses 'libcurl'.
  • libcurl — This is a library that supports many different protocols. It's very common for the PHP programming language to use this library. View the following article for further details:

This article only shows how to use the command-line tool.

cURL examples

The following examples must be ran in an SSH terminal application. View the following article for further information on how to log into a terminal.

Viewing the curl version installed

The following shows how to view the version of curl you're using. This may change depending on if you're running commands on your DreamHost server, or your local computer.

[server]$ curl --version
curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

Return the code of a specific webpage

This will return the source-coding of a specific page.

[server]$ curl

Save the code of a specific webpage in a new file

If you just run curl, the code displays in your terminal. To save it to a new file name instead, use the -o flag. This uses the lowercase 'o' character.

The syntax would be curl -o <new-file-with-saved-code> <website-url>

[server]$ curl -o 

Save the code of a specific webpage to a file of the same name

If you do not want to save to a new file name, you can save to a file that's the same as the page you're accessing. For example, if you're accessing '', this will create a new file titled 'index.html' with the saved code. Use the -O flag with a capital 'O' character.

The syntax would be curl -O <website-url>

[server]$ curl -O 

Testing a connection to a remote site

At some point, you may notice that your site is not communicating with another website. An example may be when you're attempting to download a WordPress plugin and seeing it fail.

The following steps help you test your connection to WordPress:

  1. Log into your server via SSH.
  2. Run the following command within your domain's directory:
    [server]$ curl -v
    * About to connect() to port 443 (#0)
    *   Trying connected
    * Connected to ( port 443 (#0)
    * successfully set certificate verify locations:

This first responds with connection data, then the full code of the page you entered.

The above shows a successful connection. If it failed, you'd see the failure in the response instead.

Checking headers

You can also use cURL to check headers from a website using the '-I' flag:

[server]$ curl -I
  HTTP/1.1 200 OK
Date: Tue, 29 May 2018 20:55:09 GMT
Server: Apache
Last-Modified: Mon, 25 Jul 2016 22:45:30 GMT
ETag: "2f3-5387d8a979b59"
Accept-Ranges: bytes
Content-Length: 755
Vary: Accept-Encoding
Content-Type: text/html

This returns a default list of headers. If you want a specific header not shown, you must manually specify it using the '-H' flag. For example, run the following to check if gzip is enabled:

[server]$ curl -I -H 'Accept-Encoding: gzip,deflate'
  HTTP/1.1 200 OK
Date: Tue, 29 May 2018 20:57:31 GMT
Server: Apache
Last-Modified: Mon, 25 Jul 2016 22:45:30 GMT
ETag: "2f3-5387d8a979b59"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 428
Content-Type: text/html

If gzip is enabled, you'll see this line in the output:

Content-Encoding: gzip


Moved Permanently

It's possible that when you run 'curl' on a website URL, you'll see a 'Moved Permanently' response. For example:

[server]$ curl

<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>

This usually just means the URL does (or doesn't) use the 'www' subdomain before it. Try again with (or without) www.

Otherwise, you can use the '-L' flag to redirect you anyway.

[server]$ curl -L

See also

Did this article answer your questions?

Article last updated PST.