#Running dev server on mobile
1 messages · Page 1 of 1 (latest)
Hi @stable quest. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To run a Next.js development server on your mobile device, you need to make a small configuration change. By default, Next.js only binds to localhost (127.0.0.1), which means it's only accessible from the same machine.
To make your Next.js development server accessible from other devices on your network, you need to specify the host when starting the server. You can do this by modifying your next dev command to include the host parameter:
next dev -H 0.0.0.0
Or you can update your package.json script:
{
"scripts": {
"dev": "next dev -H 0.0.0.0"
}
}
Then run npm run dev as usual. This will make your Next.js server listen on all network interfaces, making it accessible from other devices on your network.
After starting the server, you should see output showing both localhost and your network IP address. Use the network IP address (not localhost) in your mobile browser, along with the port (usually 3000), like: <http://192.168.1.x:3000.>
Make sure your mobile device is connected to the same WiFi network as your development machine, and that your firewall settings allow connections on the port Next.js is using.