# is_localhost

> **Function** in `langchain_core`

📖 [View in docs](https://reference.langchain.com/python/langchain-core/_security/_ssrf_protection/is_localhost)

Check if hostname or IP is localhost.

## Signature

```python
is_localhost(
    hostname: str,
    ip_str: str | None = None,
) -> bool
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `hostname` | `str` | Yes | Hostname to check |
| `ip_str` | `str \| None` | No | Optional IP address to check (default: `None`) |

## Returns

`bool`

True if hostname or IP is localhost

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/f0c5a28fa05adcda89aebcb449d897245ab21fa4/libs/core/langchain_core/_security/_ssrf_protection.py#L143)