Hosts file
Published
Updated
🌐
Test domains before DNS changes.
Point a domain to the IP of a fortrabbit environment in the local hosts file to test it before switching the DNS.
Test a domain before the DNS switch
The hosts file maps domain names to IP addresses on one computer only. Use it to see a site on fortrabbit under its own domain before changing the DNS for everyone:
- Add the domain to the environment in the dashboard.
- Get the IP of the environment with dig:
dig +short {{app-env-id}}.frbit.app - Add a line with that IP and the domain to the hosts file.
# IP of the environment, then the domains
203.0.113.10 example.com www.example.com
The hosts file has no file extension:
- macOS and Linux:
/etc/hosts, edit withsudo - Windows:
C:\Windows\System32\drivers\etc\hosts, edit as administrator
Leave the existing lines as they are. The browser shows a certificate warning: fortrabbit issues the TLS certificate only once the DNS points to fortrabbit.
Remove the entry
Delete the line once the DNS switch is done. The IP of an environment can change, so a forgotten entry breaks the site on that computer later.