Overview

Icanhazip is a specialized web service designed for straightforward retrieval of a client's public IP address. Since its inception in 2009, its primary function has been to provide a user's external IPv4 or IPv6 address as plain text, accessible via a simple HTTP or HTTPS request. This approach distinguishes it from more comprehensive IP geolocation or network information APIs by focusing solely on returning the IP address itself, without additional metadata. The service is suitable for situations where programmatic access to an external IP is required, such as in shell scripts, cron jobs, or embedded systems, where minimal overhead and ease of use are priorities.

Developers and system administrators commonly utilize Icanhazip for tasks like verifying network configurations, dynamically updating DNS records for services behind NAT, or conducting basic network diagnostics. For instance, a common use case involves a server behind a router needing to report its public IP to a monitoring service. Instead of manually checking, the server can make a simple request to Icanhazip and parse the direct text response. The service supports both IPv4 and IPv6, allowing clients to specify their preference or let the service detect the request's protocol.

Unlike many commercial APIs, Icanhazip operates without requiring API keys, registration, or complex authentication schemes. This design choice contributes to its utility in quick, one-off lookups and environments where dependency management needs to be minimal. Its public availability and simplicity have made it a widely adopted tool within the developer community for basic network utility functions. The straightforward nature extends to its documentation, which primarily consists of concise examples demonstrating how to query the service for different IP address formats. This focus on simplicity ensures a low barrier to entry for users across various technical skill levels.

While similar services exist, Icanhazip's longevity and consistency have established it as a reliable option for developers seeking a no-frills IP address retrieval mechanism. Its utility extends beyond simple command-line checks; for example, it can be integrated into CI/CD pipelines to ensure deployments are originating from expected IP ranges or used within cloud functions to determine the external IP assigned to ephemeral compute resources. The service prioritizes functional clarity and efficiency over feature breadth, making it a focused tool for a specific, common technical requirement.

Key features

  • IPv4 Address Lookup: Provides the client's public IPv4 address as plain text upon request. This is the default behavior when accessed via an IPv4 connection.
  • IPv6 Address Lookup: Delivers the client's public IPv6 address when accessed via an IPv6 connection. Users can explicitly request IPv6 by querying icanhazip.com/ipv6.
  • Raw IP Address Output: The service returns only the IP address itself, without any HTML wrappers, JSON objects, or additional formatting, making it easy to parse in scripts.
  • No API Key Required: Access to the service does not necessitate any registration, authentication, or API keys, simplifying integration into scripts and command-line tools.
  • HTTPS Support: Secure communication is available via HTTPS, protecting the integrity of the IP address retrieval process.
  • Host-based Output Options: Specific subdomains, such as icanhazip.com/short or icanhazip.com/long, allow for minor output variations, though the core remains a plain IP address.

Pricing

Icanhazip operates on a model that provides its core functionality free of charge for personal and non-commercial use. Commercial use is also generally permitted, though explicit guidance on high-volume commercial applications is not extensively detailed. The service relies on community support and implicit reasonable usage policies rather than a tiered subscription model.

Icanhazip Pricing Summary (as of 2026-05-28)
Plan Type Features Cost Usage Limits
Personal & Non-Commercial IPv4/IPv6 lookup, raw text output, HTTPS support Free Reasonable usage
Commercial Use IPv4/IPv6 lookup, raw text output, HTTPS support Free Reasonable usage (implied)

For specific details regarding usage policies or potential commercial arrangements beyond typical usage, users are directed to the Icanhazip homepage.

Common integrations

Icanhazip's simplicity makes it adaptable to various scripting and automation environments. Its direct text output can be easily parsed by standard command-line tools or programming language libraries.

  • Shell Scripts: Frequently integrated into Bash, Zsh, or PowerShell scripts for dynamic DNS updates, firewall rule generation, or logging external IP changes.
  • Python Applications: Used with libraries like requests to fetch and utilize the client's public IP address within Python programs, for example in network configuration tools or data collection agents.
  • Node.js Services: Can be called from Node.js backend services using http or https modules to determine the server's public egress IP for logging or registration purposes.
  • Ansible Playbooks: Employed within Ansible tasks to gather the external IP of a managed host, which can then be used in subsequent configuration steps, such as setting up security groups or access control lists.
  • Monitoring Systems: Integrated into custom monitoring scripts to track and alert on changes to a system's public IP address, ensuring consistent external accessibility.

Alternatives

Several services offer similar functionality for retrieving a client's external IP address. These alternatives vary in terms of output format, additional features, and specific API endpoints.

  • ipify: Provides a simple API for IPv4 and IPv6 addresses, also offering JSON and JSONP output options in addition to plain text.
  • whatismyip.com: A comprehensive IP information website that also offers a direct API endpoint for retrieving the user's IP.
  • ifconfig.me: Similar to Icanhazip, offering plain text IP address retrieval along with options for user agent, remote host, and port information.
  • RTCPeerConnection tricks in browsers: While not a direct service, advanced browser techniques leveraging WebRTC can sometimes reveal local and public IP addresses, though this method is more complex and less reliable for programmatic server-side use compared to dedicated IP lookup services.
  • AWS CloudFront Viewer-IP Headers: For applications hosted on AWS, CloudFront can forward the viewer's IP address through specific headers, providing a direct method to obtain client IPs within the AWS ecosystem, as detailed in CloudFront Developer Guide on Custom Headers.

Getting started

Using Icanhazip is straightforward, typically involving a simple HTTP GET request. The service responds with your public IP address directly in the response body.

To retrieve your IPv4 address using curl:

curl https://icanhazip.com

To explicitly retrieve your IPv6 address (if your network supports it):

curl https://icanhazip.com/ipv6

You can also use wget:

wget -qO- https://icanhazip.com

In Python, you might use the requests library:

import requests

try:
    response = requests.get("https://icanhazip.com")
    response.raise_for_status()  # Raise an exception for HTTP errors
    print(f"Your public IP address is: {response.text.strip()}")
except requests.exceptions.RequestException as e:
    print(f"Error fetching IP address: {e}")

For Node.js, using the built-in https module:

const https = require('https');

https.get('https://icanhazip.com', (resp) => {
  let data = '';

  resp.on('data', (chunk) => {
    data += chunk;
  });

  resp.on('end', () => {
    console.log(`Your public IP address is: ${data.trim()}`);
  });

}).on("error", (err) => {
  console.log(`Error: ${err.message}`);
});

These examples demonstrate the minimal setup required to integrate Icanhazip into various development workflows, highlighting its ease of use for quick IP address retrieval.