About curl
Curl is a command line tool to transfer data from or to a server Curl is available at the Linux command line, in the Macintosh Terminal and in the Windows Subsystem for Linux. Later versions of Windows 10 include curl in the command prompt. Curl can also be installed from https://curl.haxx.se.Using curl to troubleshoot
To use curl to test basic network connectivity, you need to know several things:- The remote server name or IP address.
- The protocol for the service to be tested (HTTP, FTP, SMTP, etc).
- The port number for the network application you want to test.
curl protocol://IP/host:port, where protocol is the communication protocol to be used IP/host represents the IP address or hostname of the server, and port represents the TCP port number. Port is optional when the standard port for a given protocol is used. For example, to connect to http://example.com on the standard port for http, type the following command:
- The server accepts the connection. If this happens, curl may display some text from the server.
- The server rejects the connection. If this happens, you receive a message such as Connection refused or Connect failed.
Troubleshooting web servers
Web server testing is probably the most common scenario for network troubleshooting. With curl, you can open a connection to a remote server on port 80 and get a response:Troubleshooting mail (SMTP) servers
Use curl to try and connect via SMTP protocol The following text shows a sample exchange between curl and a remote mail server:Troubleshooting FTP
To test an FTP server, use curl to connect via ftp protocol or to port 21. The following text shows a sample exchange between curl and a remote FTP server:More information
curl is a very versatile tool. In addition to the basic connectivity checks shown in this document, it can:- send emails
- upload and download files
- post and retrieve information from web servers