How to make an HTTP GET request manually with netcat?
Last Updated :
29 Jan, 2024
Netcat,also known as "nc", is a powerful Unix-networking utility that enables users to interact with network services through a command-line interface (CLI). It uses both TCP and UDP network protocols for communication and is designed to be a reliable back-end tool to instantly provide network connectivity to other applications and users. Although Netcat is more often known for its use in file transfers and port scanning, it can also act as an HTTP client and send and accept raw HTTP requests.
Pre-Requisites
- Basic Understanding of HTTP Requests and Response and Knowledge of HTTP Response Code.
- Working Internet/Network connection or connectivity to the target server.
- Basic Understanding of Command-line interface including Basic commands for using Netcat.
- Availability of Netcat on the host System (Comes Pre-Installed in Linux/Unix Based System).
Basic Anatomy of HTTP Requests
HTTP communications mainly consist of an HTTP request and an HTTP response. The client makes An HTTP request and is processed by the server. The requests contain all of the details we require from the server, including the resource.
An HTTP request is a message sent via an internet browser to a web server. It includes numerous components:
- HTTP method: The HTTP approach specifies the type of request being made, including GET, POST, PUT, DELETE, and many others. It shows the intended movement to be performed on resources.
- URL (Uniform Resource Locator): The URL specifies the region of the aid at the server. It includes a scheme (e.g. HTTP or HTTPS), domain name, path etc.
- Headers: Provides additional information about the request like content type, authentication, cookies etc.
- Request body: Contains optional data sent with request mainly in POST, PUT, and PATCH requests to send data.
Example of Simple HTTP GET request includes:
GET /users/login.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Ubuntu; Linux x86_64;) Firefox/78.0
Accept: text/html, application/xhtml+xml,application/xml
Accept-Language: en-US, en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Here in this example,
- GET/users/login.html is the request line which includes GET HTTP method.
- /users/login.html being the path of GET request to the resource on the server.
- Host: example.com is the header explaining the domain name of the web server where request is being sent.
Now heading back to the main topic, crafting a Netcat Command to Manually Make an HTTP GET Request with Netcat.
Getting Started with Netcat
As explained earlier, Netcat is a versatile and powerful network utility tool that uses TCP and UDP network protocols to read and write on a network. It can be used in various different scenarios, like attacking and defending web servers, and it is also used in debugging websites and web servers.
The most common uses for Netcat are given as follows:
Connecting to the server: Netcat is used to connect the server with specific port of a particular service which is running on the server.
We can connect to a server by using the following syntax on Netcat:
nc [Target IP Address] [Target Port]
For example, let's connect to a FTP server on some IP address like 192.168.1.6 with some port like 21, so the following syntax will be:
nc 192.168.1.6 21
Communication: Netcat can also be used to communicate or chat with and between two users. To chat, we need to first establish a connection between the said users. To do this, we need two devices. One can play the role of initiator to initiate and start the conversation, and one will be a listener. Once the connection is established, the communication will be a two-way communication, meaning the communication can be done from both ends.
Verbose Mode: In Netcat, we can access Verbose using the [-v] parameter. When using it, netcat generates extended information useful for debugging and troubleshooting network issues.Verbose mode generates additional information about the communication process, such as the IP address and port number of the remote host, the status of the communication, etc. Which can be helpful for diagnosing connection issues and identifying potential security threats.
File Transfer: Netcat can be used for transferring files across various devices.
A visual representation of communication between users in Netcat can be found below the following image:
Example of an communication between devices in NetcatSteps to a Manual GET Request with Netcat
Let's dive into crafting the netcat command for an HTTP GET request.
Step 1: Opening your terminal window:
On Linux, search for Terminal.
On Windows, search for Command Prompt or Windows PowerShell.

Step 2: Accessing Netcat Utility:
If Netcat is installed, you can directly run it by using nc, or you can use nc -h command to also know various built-in commands that come with the netcat.
If it's not installed on your system, you can install it using your system's package manager. For example, on Ubuntu, you can install it by using the following command:
sudo apt-get install netcat

Step 3: Connecting to the server:
Use the following command for your desired web server, followed by its port number (usually port 80 for HTTP):
nc example.com 80
Replace example .com with the actual name of the website you want to access.
Remember to replace example.com with the actual hostname.
Step 4: Sending the HTTP GET Request:
After connecting to the server, type the following HTTP GET request command, replacing the / with the path you want to access:
GET / HTTP/1.1
Host: example.com
- Replace the / and example.com with the actual path and website you want to access.
- Press ENTER twice to send the request.

Step 5: Reading the Response:
After sending the response, the web server will respond with the requested content printed on the terminal.
This response includes HTTP headers, status code, and the desired content of the requested file.
Step 6: Closing the Connection:
Once, you have received the response, you can close the connection by typing Ctrl + C on your keyboard.
Example in Action
Let's create the scenario of retrieving the homepage of google website:
Here, in this image GET / HTTP/1.1 represents the GET Request of / path for the targeted host: "google.com"
Conclusion
Manually making HTTP GET requests with Netcat is a valuable skill, which provides foundational insights to HTTP fundamentals and Web Communication. This process provides foundational understanding that is invaluable knowledge to navigate the internet.
Continued efforts towards this sector are advisable and some of the advantages are listed:
- APIs Testing: Sending custom request from Netcat to understand API functionality and Behaviour.
- Debugging Web Applications: Crafting targeted requests from netcat to diagnose issues.
- Learning Web Protocols: To gain knowledge of HTTP fundamentals and gain hands-on experience.
Similar Reads
How to Make an HTTP Request with Android?
In any Android Application, there is only so much a user can do without an internet connection. All modern Android Applications interact with resources available online or a backend-specific to the app. Â In this article, we will look at one of the ways through which we can retrieve and post resource
6 min read
How to make HTTP requests in Node ?
In the world of REST API, making HTTP requests is the core functionality of modern technology. Many developers learn it when they land in a new environment. Various open-source libraries including NodeJS built-in HTTP and HTTPS modules can be used to make network requests from NodeJS.There are many
4 min read
How To Make A GET Request using Postman and Express JS
Postman is an API(application programming interface) development tool that helps to build, test and modify APIs. In this tutorial, we will see how To Make A GET Request using Postman and Express JS PrerequisitesNode JSExpress JSPostmanTable of Content What is GET Request?Steps to make a GET Request
3 min read
How to send a POST Request with PHP ?
In web development, sending POST requests is a common practice for interacting with servers and exchanging data. PHP, a versatile server-side scripting language, provides various approaches to accomplish this task. This article will explore different methods to send POST requests using PHP. Table of
3 min read
How to Create Reverse Shells with Netcat in Kali Linux?
Netcat is a command in Linux which is used to perform port listening, port redirection, port checking, or even network testing. Netcat is also called a swiss army knife of networking tools. This command is also used to create a reverse shell. Before getting in depth of reverse shell one must be awar
2 min read
How to make a request using HTTP basic authentication with PHP curl?
Making secure API requests is a common requirement in web development, and PHP provides a powerful tool for this purpose, which is cURL. The challenge is to seamlessly integrate HTTP basic authentication with PHP cURL for secure API communication. This involves not only transmitting sensitive user c
3 min read
How to create a new request in Postman?
Postman is a development tool that is used for testing web APIs i.e. Application Programming Interfaces. It allows you to test the functionality of any application's APIs. Almost every developer uses Postman for testing purposes. We can create any type of HTTP request in it such as GET, POST, PUT, D
2 min read
How to Convert a Postman Request to cURL?
If you're a web developer, quality assurance engineer, or system administrator, chances are you're familiar with Postman, a crucial tool for API testing. However, there are instances where you may need to convert a Postman request to cURL, a command-line tool for data transfer. This article provides
3 min read
How to Make HTTP request using httr package in R Language
In this article, we will learn how to make an HTTP request using the GET method in R Programming Language with httr library. We will be covering basic steps to get you started by making HTTP requests and scrapping all the data from a site in a simple way. You can also use it to scrape data from any
2 min read
How to make an Echo server with Bash?
An Echo server is a simple network interface/application that listens for any incoming connections and requests, and then echoes back any data it receives from clients. Creating such a server is a great way to learn about network programming and the basics of client-server communication. In this art
5 min read