BuildWithMatija
Get In Touch
  1. Home
  2. Blog
  3. Tools
  4. Local DNS Override — Mirror a Production Domain Locally

Local DNS Override — Mirror a Production Domain Locally

Use a hosts file DNS override to resolve product-domain.local to production IPs for testing, QA, and red teaming

16th January 2026·Updated on:22nd February 2026·MŽMatija Žiberna·
Tools
Local DNS Override — Mirror a Production Domain Locally

📚 Get Practical Development Guides

Join developers getting comprehensive guides, code examples, optimization tips, and time-saving prompts to accelerate their development workflow.

No spam. Unsubscribe anytime.

Related Posts:

  • •Next.js 16 Self-Hosted Alternatives: Fly.io, Cloud Run, VPS
  • •ExifTool on macOS: Sync Photo & Video Metadata Fast
  • •Install Docker CLI on Mac with Colima — Fast Guide 2026

Local DNS override to mirror a production domain

This technique makes a local machine resolve an alternate hostname to a real production server. It helps with red teaming, testing client behavior, and working around tooling that blocks direct interaction with production URLs.

Goal

Access a production service using an alternate hostname on your local machine.

Example: product-domain.local resolves to the same server as product-domain.com.

Step 1: Resolve the real IP

Find the production IP address.

dig product-domain.com

Example result:

34.54.184.215

Step 2: Override DNS locally

Edit the hosts file.

sudo nano /etc/hosts

Add:

34.54.184.215 product-domain.local

Save and exit.

Step 3: Access the service https://product-domain.local

Expected behavior

The server responds normally

HTTPS shows a certificate warning because the certificate is issued for product-domain.com and the hostname is product-domain.local

This is expected and confirms the override works.

Important notes

This affects only your local machine

DNS resolution is overridden; traffic still goes to the same server

TLS hostname validation requires either accepting the warning or using HTTP

External production DNS records remain unchanged

Why this works

DNS decides where traffic goes TLS decides whether the hostname is trusted

DNS can be overridden locally TLS requires control over certificates to present a trusted hostname

📄View markdown version
0

Frequently Asked Questions

Comments

Leave a Comment

Your email will not be published

Stay updated! Get our weekly digest with the latest learnings on NextJS, React, AI, and web development tips delivered straight to your inbox.

10-2000 characters

• Comments are automatically approved and will appear immediately

• Your name and email will be saved for future comments

• Be respectful and constructive in your feedback

• No spam, self-promotion, or off-topic content

Matija Žiberna
Matija Žiberna
Full-stack developer, co-founder

I'm Matija Žiberna, a self-taught full-stack developer and co-founder passionate about building products, writing clean code, and figuring out how to turn ideas into businesses. I write about web development with Next.js, lessons from entrepreneurship, and the journey of learning by doing. My goal is to provide value through code—whether it's through tools, content, or real-world software.

You might be interested in

Next.js 16 Self-Hosted Alternatives: Fly.io, Cloud Run, VPS
Next.js 16 Self-Hosted Alternatives: Fly.io, Cloud Run, VPS

26th February 2026

ExifTool on macOS: Sync Photo & Video Metadata Fast
ExifTool on macOS: Sync Photo & Video Metadata Fast

27th February 2026

Install Docker CLI on Mac with Colima — Fast Guide 2026
Install Docker CLI on Mac with Colima — Fast Guide 2026

5th January 2026

On this page:
Build With Matija Logo

Build with Matija

Matija Žiberna

I turn scattered business knowledge into one usable system. End-to-end system architecture, AI integration, and development.

Quick Links

Projects
  • How I Work
  • Blog
  • RSS Feed
  • Services

    • Payload CMS Websites
    • Bespoke AI Applications
    • Advisory

    Payload

    • Payload CMS Websites
    • Payload CMS Developer
    • Audit
    • Migration
    • Pricing
    • Payload vs Sanity
    • Payload vs WordPress
    • Payload vs Strapi
    • Payload vs Contentful

    Industries

    • Manufacturing
    • Construction

    Get in Touch

    Have a project in mind? Let's discuss how we can help your business grow.

    Book a discovery callContact me →
    © 2026BuildWithMatija•Principal-led system architecture•All rights reserved