/Knowledge/sources/honojs__hono/llms-full/ip-restriction-middleware-usage--4d673d1f7482.md
IP Restriction Middleware: Usage - hono-docs
IP Restriction Middleware: Usage Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt usage Summary For you...
IP Restriction Middleware: Usage
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#usage
Summary
For your application running on Bun, if you want to allow access only from local, you can write it as follows. Specify the rules you want to deny in the denyList and the rules you want to allow in the allowList. ```ts import { Hono }...
Content
For your application running on Bun, if you want to allow access only from local, you can write it as follows. Specify the rules you want to deny in the denyList and the rules you want to allow in the allowList.
import { Hono } from 'hono'
import { getConnInfo } from 'hono/bun'
import { ipRestriction } from 'hono/ip-restriction'
const app = new Hono()
app.use(
'*',
ipRestriction(getConnInfo, {
denyList: [],
allowList: ['127.0.0.1', '::1'],
})
)
app.get('/', (c) => c.text('Hello Hono!'))
Pass the getConninfo from the ConnInfo helper appropriate for your environment as the first argument of ipRestriction. For example, for Deno, it would look like this:
import { getConnInfo } from 'hono/deno'
import { ipRestriction } from 'hono/ip-restriction'
//...
app.use(
'*',
ipRestriction(getConnInfo, {
// ...
})
)
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#usage",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / IP Restriction Middleware > Usage",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 135,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "IP Restriction Middleware: Usage",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}