Gist

Testing DNS and services on localhost

Local DNS and http://localhost testing guide: add loopback IP aliases, update /etc/hosts for multiple local domains, and run Next.js on custom host/IPs to test multi-domain setups on one machine.

Creating more loopback endpoints locally

sudo ifconfig lo0 alias 127.0.0.2 up

Update /etc/hosts file to point the domain to the new IP

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
127.0.0.2  	app.local
127.0.0.3	host.local

Next JS command to run on above port

npx next dev -H 127.0.0.2 -p 3001