Troubleshooting Network Applications with Curl

The curl program is a powerful tool for network troubleshooting. This guide explains how to use curl to test connectivity and diagnose network issues.

About Curl
Curl is a command-line utility used to transfer data to or from a server. It supports a wide range of protocols, including HTTP, HTTPS, FTP, and SMTP.

You can use curl in:

  • Linux: available by default in most distributions.

  • macOS: accessible via the Terminal.

  • Windows 10: included in newer versions and available through the Windows Subsystem for Linux (WSL).

  • Alternatively, curl can be downloaded from https://curl.haxx.se.

Tip:
If you’d rather not install new software, you can also use Telnet or PowerShell (tnc) for network troubleshooting—most computers already have one of these tools installed.

Using Curl to Troubleshoot
To test basic network connectivity with curl, you’ll need:

  • The server’s domain name or IP address.

  • The protocol used by the service (e.g., HTTP, FTP, SMTP).

  • The port number of the application you’re testing.

To connect to a remote server, open a terminal and type:

curl protocol://IP_or_host:port

Here:

  • protocol is the communication method (HTTP, FTP, etc.).

  • IP_or_host is the hostname or IP address.

  • port is optional if the standard port is used.

Example:

curl http://example.com

Tip:
For a full list of standard TCP and UDP port numbers, visit Wikipedia’s port list.

When you try to connect:

  • If the server accepts the connection, curl displays the server’s response or data.

  • If the server rejects it, you’ll see an error such as Connection refused or Connect failed.

Below are examples of how to troubleshoot with curl.

Troubleshooting Web Servers
Web server testing is one of curl’s most common uses. You can use it to check if a website or web server is responding.
Example:

$ curl http://example.com -I
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Mon, 13 Jan 2025 20:11:20 GMT
Cache-Control: max-age=2112
Date: Fri, 13 Jun 2025 12:57:49 GMT
Connection: keep-alive

By default, curl downloads the full web page. The -I option requests only the HTTP headers, confirming that the web server is online and responding correctly.

Troubleshooting Mail (SMTP) Servers
Curl can also test mail servers using the SMTP protocol.
Example:

$ curl smtp://example.com
214-Commands supported:
214 AUTH STARTTLS HELO EHLO MAIL RCPT DATA BDAT NOOP QUIT RSET HELP

These responses confirm that the mail server is active and ready to process requests.

Note:
If you’re testing connectivity to a ruachost.com mail server, you can also use ports 2525 or 587, since some internet providers block the default SMTP port (25) to reduce spam.

Example for port 2525:

$ curl smtp://example.com:2525
214-Commands supported:
214 AUTH STARTTLS HELO EHLO MAIL RCPT DATA BDAT NOOP QUIT RSET HELP
The response again confirms the SMTP service is available.

Troubleshooting FTP Servers
To check an FTP server, use the ftp protocol or connect directly to port 21.
Example:
$ curl ftp://example.com
curl: (67) Access denied: 530

This message indicates that the FTP server is active but requires authentication.

For more detailed information, you can connect to port 21 directly:

$ curl example.com:21
220----------
---- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 18 of 50 allowed.
220-Local time is now 12:46. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.

Either response confirms that the FTP service is online and functional.

More Information
Curl is highly versatile. Beyond simple connectivity checks, it can also:

  • Send emails.

  • Upload and download files.

  • Post or retrieve information from web servers.

To explore curl’s full capabilities:

?האם התשובה שקיבלתם הייתה מועילה 0 משתמשים שמצאו מאמר זה מועיל (0 הצבעות)

Powered by WHMCompleteSolution