Article preview image

How to Check Whether Your Server Is Online Using a Linux Command Line

We often need to check connectivity to troubleshoot network issues, or want to check whether our server is online. We created this article to show you how to do this.

There are many handy Linux tools for this:

1. ping

Ping is one of the most widely used commands to check whether a server or remote host is up and responding. Ping sends ICMP ECHO_REQUEST to the server. If ICMP is blocked from the server-side or cloud provider, then the ping command may not work as expected (like AWS ec2 instance). Here, we assume that cloud providers firewalls do not block ICMP.

Syntax: ping <destination>

root@ubuntu:~# ping
PING (2606:2800:220:1:248:1893:25c8:1946)) 56 data bytes
64 bytes from 2606:2800:220:1:248:1893:25c8:1946 (2606:2800:220:1:248:1893:25c8:1946): icmp_seq=1 ttl=59 time=2.04 ms
64 bytes from 2606:2800:220:1:248:1893:25c8:1946 (2606:2800:220:1:248:1893:25c8:1946): icmp_seq=2 ttl=59 time=1.60 ms
--- ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 1.443/1.698/2.044/0.220 ms

2. telnet

Telnet is a network protocol that allows you to connect to a remote host. Telnet is usually installed on most Linux OS by default. Otherwise, you can run the following command in the terminal:

For Redhat/CentOS/Rocky Linux

yum -y install telnet

or for Ubuntu/Debian

apt-get install telnet

Using telnet, you can identify the availability of certain ports. You can use telnet to make sure no firewalls in between are blocking incoming connections to the server.

System or network administrators use Telnet to configure network devices like routers and switches.

root@ubuntu:~# telnet localhost 22
Connected to localhost.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3

The above command shows that port 22 is open on the localhost.

Let’s now check whether the webserver port is open.

root@ubuntu:~# telnet 443
Trying 2606:2800:220:1:248:1893:25c8:1946...
Connected to
Escape character is ‘^]’.

If the port is firewalled on the remote host, then you will see something like this

root@ubuntu:~# telnet 22
Trying 2606:2800:220:1:248:1893:25c8:1946...

3. nslookup

Simply speaking, nslookup is used for DNS record checks. You can use nslookup to check if your website is connected to the internet. It is also used to troubleshoot DNS-related problems.


nslookup <domain>

It will show the IP address and other details

root@ubuntu:~# nslookup
Non-authoritative answer:
Address: 2606:2800:220:1:248:1893:25c8:1946

Otherwise you will see the following:

root@ubuntu:~# nslookup example.com1
** server can’t find example.com1: NXDOMAIN

By default, nslookup will show "A" records.

4. nmap

Nmap or Network Mapper is a powerful tool for finding open ports and network audits.

In case the nmap command is not available, you can install it executing the following command in terminal:

sudo apt install nmap

Nmap is also used to identify whether the host is up or not.


This command will show open port and host status as below:

root@ubuntu:~# nmap
Starting Nmap 7.80 ( ) at 2021-11-05 14:48 UTC
Nmap scan report for (
Host is up (0.0016s latency).
Other addresses for (not scanned): 2606:2800:220:1:248:1893:25c8:1946
Not shown: 996 filtered ports

80/tcp open http
443/tcp open https
1119/tcp closed bnetgame
1935/tcp closed rtmp
Nmap done: 1 IP address (1 host up) scanned in 4.91 seconds

You can easily check whether your server is running using the following command:


nmap -sn <hostname>

root@ubuntu:~# nmap -sn
Starting Nmap 7.80 ( ) at 2021-11-05 14:54 UTC
Nmap scan report for (
Host is up (0.0023s latency).

5. nc

Netcat is known as an nc command used for network scanning like Port Scanning, open Remote connections, Network debugging, read and write operation on the network, and many more.

You can easily check the reachability of remote ports using nc Command.


nc -vz $HOSTNAME $PORTnc -vz 443

If port 443 is running on the server, we will get the following:

Connection to 443 port [tcp/https] succeeded!

root@ubuntu:~# nc -vz
nc: missing port number
root@ubuntu:~# nc -vz 443
Connection to 443 port [tcp/https] succeeded!
root@ubuntu:~# nc -vz 80
Connection to 80 port [tcp/https] succeeded!

6. wget

Wget is a command-line download tool that supports HTTP, HTTPS and FTP. Wget is very useful for those who want to check any network-related issue or test connection from a Linux terminal. It will help you in web-related issues debugging.


wget <URL>

root@ubuntu:~# wget
--2021-11-05 17:48:52–
Resolving ( 2606:2800:220:1:248:1893:25c8:1946,
Connecting to (| 2606:2800:220:1:248:1893:25c8:1946|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1256 (1.2K) [text/html]
Saving to: índex.html.2
index.html.2 100%[=========================>] 1.23K --.-KB\s in 0s2021-11-05 17:48:52 (74.6 MB/s) - ’index.html.2’saved [1256/1256]

Here we get the “200” response code from the web server and index.html file downloaded.

7. curl

You can use the curl command to transfer data either from or to a server. It supports proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, and many more.

You can use curl command to test TCP ports connectivity.

Let’s check our SSH port connection with CURL


curl -v telnet://

root@ubuntu:~# curl -v telnet://
* Trying
* Connected to ( port 22 (#0)

Now let’s check whether our web server is running on port 80 using curl

root@ubuntu:~# curl -v telnet://
* Trying 2606:2800:220:1:248:1893:25c8:1946:80
* Connected to (2606:2800:220:1:248:1893:25c8:1946) port 80 (#0)

Let’s check the SMTP port

root@ubuntu:~# curl -v telnet://
* Trying
* Connected to port 25 failed: Connection refused
* Failed to connect to port 25: Connection refused
* Closing connection 0
curl: (7) Failed to connect to port 25: Connection refused

As you see, CURL is a useful command-line tool available in Linux to check the connection with the server and port.

We have examined the Linux command-line tools for checking server health and network connectivity in detail. These are essential tools for system and network administrators to troubleshoot any network-related issues.