1. Home
  2. Domains & DNS
  3. How do I temporarily point a domain towards another server locally?

How do I temporarily point a domain towards another server locally?

To locally point a domain using a hosts file makes it very easy to test a website you’ve built on another server without affecting general access to the current website.

If the website you’re building is using a CMS such as WordPress or Magento, you will not have to go through the hassle of changing the URL the site is using. If you on the other hand use a temporary domain, you’ll need to update all URLs on the site once you’re ready to go live.

Below, we describe how you point a domain locally in the most commonly used operating systems.

Keep in mind that you need to set up an SSL certificate if the site is going to use https, even when you point the domain locally. As long as the domain isn’t pointed globally towards our server, you can use a self-signed SSL certificate to enable https.

Windows 7, 8, and 10

  1. Open Notepad as administrator: In Windows 8 and 10, press the Windows key on your keyboard and start typing Notepad to find the program. In Windows 7, use the search field under the Start menu to find it. Either way, right-click the program and click Run as Administrator.
  2. Open the hosts file in the program via File -> Open. In the filename field, enter C:\Windows\System32\drivers\etc\hosts.
  3. You will now see number of comment lines (starting with #). Add an IP address and the domain you want to point at the bottom of the file. If the domain is to be pointed towards a web hosting account on our servers, you can find the correct IP address via these instructions. Below follows examples of such rows:
91.201.63.148       exempel.se
91.201.63.148       www.exempel.se

Please note that the IP address in this example might not be the one for your account’s server. Refer to this guide to find the correct one.

  1. Don’t forget to save the hosts file ones you’re done editing it! If the program tells you you cannot save, make sure that you started Notepad as administrator.

MacOS 10.6+ and Linux/Unix

  1. Begin by opening a terminal:
    1. On macOS, press cmd + space on your keyboard and type terminal, and press Enter. You can also find the app Terminal via the Utilities folder in your Applications folder, if you rather click your way to the app.
    2. If you’re using Linux/Unix, start your favourite terminal. Which ones you have access to vary depending on your distribution.
  2. Open the hosts file with a text editor as the root user, e.g. with the command sudo nano /etc/hosts. Keep in mind that your user must have sudo permissions on Linux/Unix for this to work. If you run macOS, your user needs to be administrator.
  3. Add the IP address and the domain on a new line at the end of the file (in the same way as displayed in the Windows example above), and save it. If you use nano, you can save by pressing ctrl + X on your keyboard and confirm that you want to save with the Y key.

Don’t forget to clear the cache in your web browser if you still see website from the server whereto the domain is pointed globally.
If you run Windows, you may have to clear the DNS cache as well. You can do this via the Command prompt with the command ipconfig /flushdns.

Was this article helpful?

Related Articles