> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting network applications with curl

> The cURL program is valuable as a network troubleshooting tool. Learn how to use it in this article.

There are many online tools for testing the services offered by a server but those tests only indicate the view from the online tool. Sometimes you need to test connectivity from your local computer. This article describes how to use curl to troubleshoot network applications.

## 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](https://curl.haxx.se).

<Tip>
  Don't want to install software? Try our articles on network troubleshooting [using telnet](/docs/troubleshooting-network-applications-with-telnet) or\
  [using PowerShell and tnc](/docs/troubleshooting-network-applications-with-powershell-and-tnc). Just about every computer will have one of these three programs installed.
</Tip>

## 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.

To open a connection to a remote server, open a terminal window on your computer, and then type `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:

```bash theme={null}
curl http://example.com
```

<Tip>
  For a complete list of assigned TCP port numbers and their associated protocols, please visit\
  [http://en.wikipedia.org/wiki/List\_of\_TCP\_and\_UDP\_port\_numbers](https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers).
</Tip>

When you try to establish a connection to a remote server, one of two things happens:

* 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.

The following sections demonstrate how to do basic troubleshooting with curl.

### 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:

```
$ 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
```

curl returns the entire content of the web page by default so in this example the -I option is added to return only the header. The HTTP response confirms that the server is accepting connections and responding to requests.

### 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:

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

The SMTP responses show the server is running and accepting requests.

Some ISPs block port the standard SMTP port (25) to help reduce spam on their networks. If you are testing connectivity to a hosting.com mail server, you can also use port 2525 or 587.

For example, to try and connect to SMTP on port 2525, add the optional port number at the end of the command. The following text shows a sample exchange between curl and a remote mail server using port 2525:

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

The SMTP responses show the server is running and accepting requests.

### 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:

```
$ curl ftp://example.com
curl: (67) Access denied: 530
```

Because a valid user name was not supplied, curl returns*Access denied*.

More detail is available by using the FTP port (21) without the FTP protocol.

```
$ 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 indicates the FTP server is active and running.

## 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

Download and read about curl at the [curl website](https://curl.haxx.se/).

Read the [curl book online](https://ec.haxx.se/).

## Related articles

* [Troubleshooting network applications with PowerShell and tnc](/docs/troubleshooting-network-applications-with-powershell-and-tnc)

* [Troubleshooting network applications with telnet](/docs/troubleshooting-network-applications-with-telnet)

* [Internet and networking](/docs/internet-and-networking)

* [Introduction to network troubleshooting](/docs/introduction-to-network-troubleshooting)

* [Troubleshooting network connectivity using ping and traceroute](/docs/troubleshooting-network-connectivity-with-ping-and-traceroute)

* [Testing DNS with dig and nslookup](/docs/troubleshooting-dns-with-dig-and-nslookup)
