CURL
lastmod 2025-07-02created 2014-02-1778 edits
cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. The cURL project produces two products, libcurl and cURL. It was first released in 1997.
Provides a command-line program and a C API library that support data transfer using various protocols.
Categories
Examples
Too many, so split into a separate page.
Alternatives
- Invoke-WebRequest aka iwr (PowerShell)
- aria2 - Fast multi-protocol, multi-download command line.
Checking your global IP
Visit a site that shows your global IP:
-
curl ifconfig.me -
curl ident.me -
curl ifconfig.me -
curl icanhazip.com -
curl ipecho.net/plain -
curl ipv4.icanhazip.com
Options
-
-f,--fail - If the HTTP status code is not
200, propagates an error to the exit code. Needed when writing command-line scripts.
-
--connect-timeout - Maximum time in seconds that you allow the connection to the server to take.
-
-m,--max-time - Maximum time in seconds that you allow the whole operation to take.
-
-s,--silent - Silent or quiet mode.
- So if you don't want any output use:
curl -s 'http://example.com' > /dev/null
-
-L,--location - When a
301 Moved Permanentlyerror occurs, follows the Location information in the header and moves to the new address.
-
-o [FILE] - Specifies the name of the file to download to.
-
curl -o index.htmlhttp://www.netscape.com/
-
-O - Downloads using the file name from the web page.
-
curl -Ohttp://www.netscape.com/index.html
-
-u/--user [username][:passwd] - ID and PASSWORD for authentication.
-
-e [Referrer URL] - Sets the referrer (referer). (referrer)
-
--max-filesize [size] - Limits the size of the file to download.
-
-T/--upload-file [FILE] - Transfer file to remote site.
-
-s/--silent - Silent mode. Don't output anything.
-
-S/--show-error - Show error. With -s, make curl show errors when they occur.
-
-m/--max-time [seconds] - Maximum time allowed for the transfer.
-
--connect-timeout [seconds] - Maximum time allowed for connection.
-
--ftp-create-dirs - Create the remote dirs if not present (F).
-
--verbose,--trace,,--trace-ascii - Protocol debugging. Gives detailed information about the HTTP data exchange. If verbose is not enough, use trace-ascii.
-
-k,--insecure - Forces a connection even to insecure servers. Verifies the server connection by checking that the server's certificate contains the right name, and verifies it successfully using the certificate store.
- https://curl.haxx.se/docs/sslcerts.html
- See also the
--proxy-insecureand--cacertoptions. - The environment variable
CURLOPT_SSL_VERIFYHOST=0might also work? <- Needs checking.
Error codes
- CURLE_OK (0)
- All fine. Proceed as usual.
- CURLE_OPERATION_TIMEDOUT (28)
- Operation timeout. The specified time-out period was reached according to the conditions.
- CURLM_ADDED_ALREADY (7)
- An easy handle already added to a multi handle was attempted to get added a second time. (Added in 7.32.1)
- CURLE_GOT_NOTHING (52)
- Nothing was returned from the server, and under the circumstances, getting nothing is considered an error.
Adding to the certificate authority list
Run curl with the -v option to see where it loads the CA list from.
$ curl -v https://google.com
* About to connect() to google.com port 443 (#0)
* Trying 74.125.128.139... connected
* Connected to google.com (74.125.128.139) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
- Ubuntu loads the CA list from
/etc/ssl/certs/ca-certificates.crtor the/etc/ssl/certsdirectory - RHEL/CentOS loads the CA list from
/etc/pki/tls/certs/ca-bundle.crt, as shown below - Mac OSX loads the CA list from
/etc/ssl/cert.pem
See OpenSSL for how to extract certificates.
Running a downloaded script directly in the Bash shell or PowerShell without saving it to a file
See the sample from k3s:
In short:
For reference, if you want a similar command in PowerShell:
Alternatives when curl is not available
See also
- URI
- URL
- URN
- wget
- Fiddler
- WireShark
- ciao - Simple HTTP server monitoring tool
- aria2 - aria2 is a lightweight multi-protocol & multi-source command-line download utility.
- crul - A tool that queries any web page or API for free
- resty - Command line
- HTTPie (httpie) - Command line
- Vim REST Console - vim plugin
- Posting - HTTP API client for the terminal
- Pipet - CLI tool for scraping/extracting data online
- ArchiveBox - ArchiveBox self-hosts an internet archive
- Hurl - Text-based tool for HTTP requests and testing on the command line
- Vet – A tool for running remote shell scripts more safely
Favorite site
- cURL website 1
- Wikipedia (en) description of cURL
- Mastering Curl: Interactive Text Guide | GeekNews
- [Original] Mastering curl: interactive text guide
- A short text guide summarizing the 3.5-hour "Mastering the curl command line" workshop video by curl developer Daniel Stenberg
- Lets you run various curl options instantly on the web page, along with explanations
- Uses the codapi (code playground) widget
Related Tools
References
-
Document page: Curl.haxx.se.zip ↩
Pages that link here
- AppVeyor
- Apt-key
- Aria2
- Bash
- Ciao
- Crul
- CURL:Examples
- DNS over HTTPS
- Docker Compose
- Flask
- Graphqurl
- Healthcheck
- HTTP:Headers:Referer
- HTTPie
- Hurl
- Hypertext Transfer Protocol
- Invoke-WebRequest
- Libcurl
- Mitmproxy
- Network-attached storage
- Oh My Zsh
- Pipet
- Posting
- Programming
- Proxy server
- Python:urllib
- QR code
- Resty
- Server Message Block
- Shell:Basic
- SolutionStack:FullStackDeveloper:Curriculum
- SonatypeNexus:Apt
- Tar
- Vim REST Console
- Vim-rest-console
- Web development
- Wget
- Windows PowerShell