{"id":416,"date":"2025-11-20T14:45:38","date_gmt":"2025-11-20T14:45:38","guid":{"rendered":"https:\/\/www.jolt.co.uk\/kb\/editing-the-hosts-file\/"},"modified":"2025-11-20T14:45:38","modified_gmt":"2025-11-20T14:45:38","slug":"editing-the-hosts-file","status":"publish","type":"post","link":"https:\/\/www.jolt.co.uk\/help\/editing-the-hosts-file\/","title":{"rendered":"Editing the hosts file"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the Hosts File?<\/h2>\n\n\n\n<p>The hosts file tells your computer which IP address to use for a specific domain name, overriding public DNS. This is useful for testing a website on a new server before updating DNS publicly.<\/p>\n\n\n\n<p><strong>Common use case:<\/strong> You&#8217;ve built a new website on our servers but your domain still points to your old host. You can edit your operating system&#8217;s &#8220;hosts&#8221; file to point a domain at a given IP to preview the new site before going live.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Before You Start<\/strong><\/h2>\n\n\n\n<p>You&#8217;ll need:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Server IP address<\/strong> (find this in your hosting control panel or contact support)<\/li>\n\n\n\n<li><strong>Your domain name<\/strong><\/li>\n\n\n\n<li><strong>Administrator access<\/strong> to your computer<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>macOS and Linux<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Open Terminal<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>macOS:<\/strong> Search for &#8220;Terminal&#8221; in Spotlight (Cmd + Space)<\/li>\n\n\n\n<li><strong>Linux:<\/strong> Use universal search (Ubuntu, Fedora, Almalinux etc.)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Edit the Hosts File<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Type: <code>sudo nano \/etc\/hosts<\/code><\/li>\n\n\n\n<li>Enter your administrator password when prompted<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Add Your Domain<\/strong><\/h3>\n\n\n\n<p>Add these lines at the bottom (replace with your IP and domain):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>194.110.243.194 yourdomain.uk<br>194.110.243.194 www.yourdomain.uk<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"banner-tip\">\ud83d\udc49 <strong>Tip:<\/strong> Always add both versions (with and without <code>www<\/code>)<\/p>\n\n\n\n<p><strong>Optional &#8211; IPv6:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>2a00:b980:2::242 yourdomain.uk<br>2a00:b980:2::242 www.yourdomain.uk<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Save and Exit<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Press <strong>Ctrl + O<\/strong> to save<\/li>\n\n\n\n<li>Press <strong>Enter<\/strong> to confirm<\/li>\n\n\n\n<li>Press <strong>Ctrl + X<\/strong> to exit<\/li>\n\n\n\n<li>Close Terminal<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Microsoft <strong>Windows<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Open Notepad as Administrator<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click <strong>Start<\/strong> or press the Windows key<\/li>\n\n\n\n<li>Type <strong>&#8220;Notepad&#8221;<\/strong><\/li>\n\n\n\n<li><strong>Right-click<\/strong> Notepad \u2192 Select <strong>&#8220;Run as administrator&#8221;<\/strong><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"487\" src=\"https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-29.png\" alt=\"\" class=\"wp-image-422\" srcset=\"https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-29.png 468w, https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-29-288x300.png 288w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Open the Hosts File<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In Notepad: <strong>File<\/strong> \u2192 <strong>Open<\/strong><\/li>\n\n\n\n<li>Navigate to: <code>C:\\Windows\\System32\\Drivers\\etc\\<\/code><\/li>\n\n\n\n<li>Change file type dropdown to <strong>&#8220;All Files (<em>.<\/em>)&#8221;<\/strong><\/li>\n\n\n\n<li>Select <strong>&#8220;hosts&#8221;<\/strong> and click <strong>Open<\/strong><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"365\" height=\"372\" src=\"https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-31.png\" alt=\"\" class=\"wp-image-420\" srcset=\"https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-31.png 365w, https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-31-294x300.png 294w\" sizes=\"auto, (max-width: 365px) 100vw, 365px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Add Your Domain<\/strong><\/h3>\n\n\n\n<p>Add these lines at the bottom (replace with your IP and domain):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>194.110.243.194 yourdomain.uk<br>194.110.243.194 www.yourdomain.uk<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"banner-tip\">\ud83d\udc49 <strong>Tip:<\/strong> Always add both versions (with and without <code>www<\/code>)<\/p>\n\n\n\n<p><strong>Optional &#8211; IPv6:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>2a00:b980:2::242 yourdomain.uk<br>2a00:b980:2::242 www.yourdomain.uk<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Save and Close<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Press <strong>Ctrl + S<\/strong> or <strong>File<\/strong> \u2192 <strong>Save<\/strong><\/li>\n\n\n\n<li>Close Notepad<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"507\" src=\"https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-34.png\" alt=\"\" class=\"wp-image-417\" srcset=\"https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-34.png 875w, https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-34-300x174.png 300w, https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-34-768x445.png 768w, https:\/\/kb.jolt.co.uk\/wp-content\/uploads\/sites\/5\/2025\/11\/image-34-770x446.png 770w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Testing Your Changes<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Close and reopen your browser<\/strong> (or clear browser cache)<\/li>\n\n\n\n<li>Visit your domain &#8211; it should now load from the new server<\/li>\n\n\n\n<li>Check the IP by opening Command Prompt\/Terminal and typing:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>ping yourdomain.uk<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Important: Remove Entries After Going Live<\/strong><\/h2>\n\n\n\n<p>\u26a0\ufe0f <strong>Once your DNS is updated and live<\/strong>, remove the hosts file entries by:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Repeating the steps above<\/li>\n\n\n\n<li><strong>Deleting<\/strong> the lines you added<\/li>\n\n\n\n<li>Saving the file<\/li>\n<\/ol>\n\n\n\n<p><strong>Why?<\/strong> Leaving these entries will cause your computer to always use the old IP, even after DNS changes.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Finding Your Server IP Address<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check your <strong>hosting control panel<\/strong> (cPanel, Scout, etc.)<\/li>\n\n\n\n<li>Look for &#8220;Server Information&#8221; or &#8220;IP Address&#8221;<\/li>\n\n\n\n<li>Or contact support at www.jolt.co.uk\/support\/ and we&#8217;ll provide it<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Troubleshooting<\/strong><\/h2>\n\n\n\n<p><strong>Changes not working:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Close and reopen your browser completely<\/li>\n\n\n\n<li>Clear browser cache (Ctrl + Shift + Delete)<\/li>\n\n\n\n<li>Flush DNS cache:\n<ul class=\"wp-block-list\">\n<li><strong>Windows:<\/strong> <code>ipconfig \/flushdns<\/code> in Command Prompt<\/li>\n\n\n\n<li><strong>macOS:<\/strong> <code>sudo dscacheutil -flushcache<\/code> in Terminal<\/li>\n\n\n\n<li><strong>Linux:<\/strong> <code>sudo systemd-resolve --flush-caches<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Can&#8217;t save hosts file (Windows):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Make sure you opened Notepad as Administrator<\/li>\n<\/ul>\n\n\n\n<p><strong>Can&#8217;t edit hosts file (Mac\/Linux):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Make sure you used <code>sudo<\/code> in the command<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Need Help?<\/strong><\/h2>\n\n\n\n<p>Our support team can assist with hosts file configuration! Contact us at www.jolt.co.uk\/support\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is the Hosts File? The hosts file tells your computer which IP address to use for a specific domain name, overriding public DNS. This is useful for testing a website on a new server before updating DNS publicly. Common use case: You&#8217;ve built a new website on our servers&hellip;<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,9,12,15],"tags":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-access","category-advanced-techniques","category-domains","category-reseller"],"_links":{"self":[{"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":1,"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":423,"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/posts\/416\/revisions\/423"}],"wp:attachment":[{"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jolt.co.uk\/help\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}