Skip to content
WebHostsOnline Web-Solutions
  • Home
  • Domains
    • Domains
    • Transfer Your Domain
    • Order SSL Certificates
  • Cloud Hosting
    • AWS Hosting
    • Cloud i Hosting from WebHostsOnline
    • Google Cloud Servers
    • Magento Hosting
    • WooCommerce Hosting
    • Timeline Backups
  • Hosting
    • Shared Hosting
    • Website Builder
    • Website Design & Hosting
  • Email Hosting
  • WordPress
    • Free Hosting
    • WooCommerce Hosting
    • WordPress Hosting
  • VPS Hosting
  • Tools
    • SSL Certificates
    • Timeline Backup-Pro
    • Website Turbo
  • My Account
Contact Us
alt
WebHostsOnline Web-Solutions
  • hello@webhostsonline.co.uk
back to top

How to modify your hosts file for Windows, macOS and Linux.

  • WebHostsOnline Web-Solutions
  • /knowledge-base
  • Web Hosting
  • How to modify your hosts file for Windows, macOS and Linux.

My Account

3
  • How do I register a new domain with WebHostsOnline?
  • Which nameservers should I use with WebHostsOnline hosting?
  • Where can I update my account / profile details?

Cloud Servers

10
  • How do I add another server/include to an SPF record?
  • Managed Cloud Server: Manage Your Cloud Server
  • Managed Cloud Server: Registering Domain Names
  • How can I clone a site with Timeline Backups?
  • How do I restore a site using Timeline Backups?
  • How do I set up Automatic Timeline Backups?
  • Does your hosting support Django?
  • Does your Windows hosting support .NET Core?
  • How do I activate my free SSL?

Domains

10
  • How can I create a subdomain?
  • Managed Cloud Server: Registering Domain Names
  • Domain transfer statuses explained?
  • What are WebHostsOnline nameservers?
  • How to transfer your domain from 123-reg WebHostsOnline
  • How to transfer your domain from Ionos to WebHostsOnline
  • How to transfer your domain from GoDaddy to WebHostsOnline
  • How to transfer your domain from Easyspace to WebHostsOnline
  • My domain is locked with my current provider, what can I do?
  • How do I transfer my domain to you?

Email Hosting

13
  • How to create an autoresponder?
  • How do I add Office 365 DNS records?
  • Why are the IMAP folders missing from my iPhone or iPad?
  • What are the recommended Thunderbird Mail client settings?
  • How do I add another server/include to an SPF record?
  • WordPress: use SMTP with and without plugins
  • What are the Free Tools with WordPress Hosting?
  • How do I use the free WebHostsOnline Website Malware Scanner? 
  • What are my email sending limits?
  • How do I set up email on my iPhone?
  • How do I set up my WebHostsOnline mailbox in Outlook?
  • How do I create a mailbox?
  • How to use the email migration tool

FTP

2
  • How to connect Web Hosting via FTP?
  • I can’t connect via FTP, what can I do?

Web Hosting

18
  • How can I clone a site with Timeline Backups?
  • How do I restore a site using Timeline Backups?
  • How do I set up Automatic Timeline Backups?
  • Does your hosting support Django?
  • WordPress caching: what you need to know
  • Do I need caching plugins in addition to the WebHostsOnline CDN?
  • Why am I getting a cache status ‘MISS’?
  • How do I use WebHostsOnline’s CDN?
  • How do I create a Website Acceleration Suite template?
  • Improve your WordPress website’s TTFB
  • What is the Website Acceleration Suite?
  • Why could my WordPress migration fail?
  • Do you support WordPress multisite?
  • How do I activate my free SSL?
  • How do I run a search and replace in the WordPress CLI?
  • How do I create a MySQL database in MyWebHostsOnline
  • How do I change PHP version?
  • How to modify your hosts file for Windows, macOS and Linux.

WordPress

21
  • I installed WordPress on the temporary URL, how can I change it to my domain name?
  • WordPress Multisite Setup Guide
  • How can I clone a site with Timeline Backups?
  • How do I restore a site using Timeline Backups?
  • How do I set up Automatic Timeline Backups?
  • Why do I get an Internal Server Error 500 and how to fix it?
  • WordPress: use SMTP with and without plugins
  • WordPress caching: what you need to know
  • Do I need caching plugins in addition to the WebHostsOnline CDN?
  • Why am I getting a cache status ‘MISS’?
  • How do I use WebHostsOnline’s CDN?
  • How do I create a Website Acceleration Suite template?
  • Improve your WordPress website’s TTFB
  • What is the Website Acceleration Suite?
  • Why could my WordPress migration fail?
  • Do you support WordPress multisite?
  • How do I activate my free SSL?
  • How do I run a search and replace in the WordPress CLI?
  • Is it safe to update the PHP version on my website?
  • How do I migrate a website manually?
  • WooCommerce
    • WordPress Multisite Setup Guide

Migrations

3
  • Why could my WordPress migration fail?
  • How do I migrate a website manually?
  • How to modify your hosts file for Windows, macOS and Linux.

SSL Certificates

2
  • How do I activate my free SSL?
  • Can I use the free SSL if my site doesn’t use the WebHostsOnline nameservers?

Security

3
  • What are the Free Tools with WordPress Hosting?
  • How do I use the free WebHostsOnline Website Malware Scanner? 
  • Protecting your password from brute-force attacks

DataBase

13
  • How to connect Web Hosting via FTP?
  • MS-SQL
    • How do I import a .sql file via the command-line?
    • How do I manage my Microsoft SQL database?
    • What is MS-SQL?
  • MySQL
    • How do I export a .sql file via the command-line
    • How do I download or back up my MySQL Database?
    • How do I import a .sql file via the command-line?
    • Can I view my FTP, email address, or database passwords?
    • How do I create a MySQL database?
    • What’s the maximum MySQL database size allowed?
    • Can I set my database hostname as ‘localhost’?
    • How do I import a .sql file via phpMyAdmin?
    • What is MariaDB?

VPS

14
  • How do I connect to my Windows virtual machine via Remote Desktop?
  • How set up Mastodon on a Self-Managed VPS
  • How do I connect to an Unmanaged VPS using SSH?
  • How do I install and enable Apache and PHP modules on my cPanel VPS?
  • Does your hosting support Django?
  • How do I raise an additional IP address on my CentOS virtual machine?
  • How do I add an additional IP address to my virtual machine?
  • What version of Windows do you run on the Windows servers?
  • Does your Windows hosting support .NET Core?
  • How do I connect to my Windows virtual machine via Remote Desktop?
  • Windows
    • How do I connect to my Windows virtual machine via Remote Desktop?
    • Managing the Windows Application Pool
    • What version of Windows do you run on the Windows servers?
    • Does your Windows hosting support .NET Core?

Backups

3
  • How can I clone a site with Timeline Backups?
  • How do I set up Automatic Timeline Backups?
  • How do I restore a site using Timeline Backups?

SSH

8
  • Can I use sudo on shared hosting?
  • What is the PHP memory_limit?
  • How do I connect via SSH using 2FA?
  • How do I connect via SSH?
  • How do I import a .sql file via the command-line?
  • How do I connect via SSH on an Apple Mac?
  • How do I connect via SSH on an Apple Mac?
  • How do I run Composer via SSH?
View Categories
  • Home
  • /knowledge-base
  • Web Hosting
  • How to modify your hosts file for Windows, macOS and Linux.

How to modify your hosts file for Windows, macOS and Linux.

1 min read

AI Doc Summarizer Doc Summary
AI Doc Summarizer Thinking Thinking

Your machine’s local hosts file allows you to override DNS for a particular domain or subdomain name.

This is a great way to test the site ahead of changing real DNS: you’re able to test the website at WebHostsOnline while the rest of the internet continues to use DNS to point to the existing website.

The way to modify this file and the location of it differs by the operating system.

To modify your hosts file, you can add two entries to the file that contains the IP address that you want the site to resolve to. Adding the following two lines, for example, would point www.domain.com and domain.com to the IP 1.2.3.4:

1.2.3.4 domain.com www.domain.com

Modify hosts file on Windows:

  • Press Start and Search for Notepad
  • In the search results, right-click Notepad and select Run as administrator. (this bit’s important!)
  • Use File -> Open and navigate to the following file: c:\Windows\System32\Drivers\etc\hosts
  • Make the changes (see below)

For Mac OS 10.0 to 10.6:

  • Open Applications > Utilities > Terminal
  • Type sudo nano /etc/hosts
  • Enter the administrator password
  • Make the changes (below) 

To save changes in nano, press Control+x and then y when prompted.

Modify hosts file for Mac OS X 10.6 through 12:

  • Open Applications > Utilities > Terminal
  • Type sudo nano /private/etc/hosts
  • Enter the administrator password
  • Make the changes (below)
  • Type dscacheutil -flushcache in to Terminal and press enter.

To save changes in nano, press Control-x and then “y” when prompted.

How to modify hosts file for Linux:

  • Use your favourite editor to open /etc/hosts (i.e sudo vim /etc/hosts)
  • Make the changes (below)

Making The Change

The hosts file takes arguments of the format:

XX.XX.XX.XX domain.com www.domain.com

The IP address for the website is displayed down the right-hand side of the hosting package overview page in MyWebHostsOnline. To get to this page, head to Manage Hosting, find the hosting package and select Options > Manage. Once on the overview page, the IP address can be found under the Account Information heading. They’ll usually start with ‘185.151.3x.xxx’:

185.151.3x.xxx domain.com www.domain.com

After you add this line and save the file, your system begins resolving to the specified IP address.

If you also have subdomains that you’d like to resolve to your WebHostsOnline hosting package, you can add them like this:

185.151.3x.xxx domain.com www.domain.com sub.domain.com

After testing is finished please remove these entries so you start using “real DNS” once again.

It’s important to ensure that when making this change you have entries for both your domain and all relevant subparts. For example, if you just add an entry for “domain.tld”, then “www.domain.tld” will point the original server. The same goes for any subdomains

Updated on September 23, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
How do I change PHP version?How can I clone a site with Timeline Backups?

Powered by BetterDocs

Leave a Comment Cancel reply

WebHostsOnline Web-Solutions

Contact

  • Church Yard,
    Ashford Kent.
    TN23 1QG
  • hello@webhostsonline.co.uk

Links

  • Cloud Hosting
  • Joomla Hosting
  • Laravel Hosting
  • .Net Core Hosting
  • NodeJS Hosting
  • PHP Hosting
  • VPS Hosting
  • My WebHostsOnline Demo
  • WebMail

Support

  • Contact Us
  • Knowledge Base
  • System Status

Company

  • About
  • Blog
  • Cookie Policy
  • Disclaimer
  • Imprint
  • Privacy Statement
  • Terms and Conditions
  • Website Design Service Terms and Conditions of Service

All rights reserved © WebHostsOnline Web-Solutions. | Part of the GMCi Group
Registration No. 17215955, Registered in England and Wales.

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behaviour or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}