skip to content
Hiiruki's lab

How to expose port in Astro dev server

/ 1 min read

Table of Contents

Intro

By default, Astro dev server only expose port to localhost. But sometimes we need to expose port to network so that other devices can access it. Here’s how to do it.

How to

Start the Astro dev server with the --host flag.

Terminal window
$ npx astro dev --host 0.0.0.0 --port 4321

Check the Windows firewall to make sure that the port is open

Terminal window
C:\Users\hiiruki> netstat -an | findstr 4321
TCP 127.0.0.1:4321 0.0.0.0:0 LISTENING