What is IP Address and Port? A Beginner-Friendly Explanation
When we browse the internet, send emails, or stream videos, we rarely think about how our devices talk to each other. Behind the scenes, two very important concepts make this communication possible: IP addresses and ports. Let’s break them down in simple terms.
🔹 What is an IP Address?
An IP address (Internet Protocol address) is like the building address of your computer on a network.
- It uniquely identifies a device (computer, phone, or server) so other devices know where to send data or receive data from.
- Without an IP address, data would never reach the right destination.
Example:
- IPv4:
142.250.191.142
- IPv6:
2607:f8b0:4004:c0b::66
🔹 What is a Port?
Now, just knowing the building address (IP) isn’t enough. We also need to know which flat/room inside should receive the letter. That’s where ports come in.
A port is a logical number (ranging from 0 to 65535) that tells the computer which application or service should handle the data.
Example:
- Port 80 → Used for HTTP websites
- Port 443 → Used for HTTPS (secure websites)
- Port 25 → Email sending (SMTP)
- Port 22 → Secure remote login (SSH)
When you type https://example.com
, your browser does the following:
- DNS lookup: It first finds the IP address of
example.com
using the Domain Name System (DNS). - Connect to the server: By default, for HTTPS, it connects to port 443 on that server. (For HTTP, the default is port 80.)
- Open the site: After establishing the connection, it communicates with the server to load the website.
Important: If the website uses a non-standard port (not 443 for HTTPS or 80 for HTTP), you must explicitly include it in the URL.
For example:
https://example.com:8443
Here, 8443
is the custom port the browser will connect to instead of the default 443.
How IP and Port Work Together
Think of it like this:
- IP Address = Building address of the computer
- Port Number = Flat/room number inside the computer
So if you want to visit your friend John in Flat/Room 443, you don’t just need the building address (IP). You also need his Flat/Room number (port).
How to See Connected Ports on Your Computer
If you’re curious which ports your laptop is using right now:
On Windows:
netstat -an
On macOS/Linux:
lsof -i -P -n
This will show you all the active IP:Port connections your system is currently using.
Final Thoughts
- The IP address makes sure data reaches the right device.
- The port number makes sure it reaches the right application on that device.
Together, they form the foundation of how the internet works.
Next time you open a website or send an email, you’ll know that behind the scenes, your device is using an IP address and a port number to deliver your request safely and correctly!