{"id":139,"date":"2020-01-15T16:54:49","date_gmt":"2020-01-15T16:54:49","guid":{"rendered":"http:\/\/localbyflywheel.com\/?post_type=help&#038;p=139"},"modified":"2023-07-28T18:02:00","modified_gmt":"2023-07-28T18:02:00","slug":"router-mode","status":"publish","type":"help","link":"https:\/\/localwp.com\/help-docs\/advanced\/router-mode\/","title":{"rendered":"What is Router Mode?"},"content":{"rendered":"\r\n<p class=\"wp-block-paragraph\">Ideally, you would never have to know about this setting. But here you are; I&#8217;m sorry and welcome to the club! <\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">So what <em>is<\/em> Router Mode?<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Router Mode is Local&#8217;s way of offering the best offline development experience possible while still &#8220;playing nice&#8221; with other, similar development applications.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">You can access this setting by navigating to &#8220;Preferences &gt; Advanced &gt; Router Mode,&#8221; where you will find two options:<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li><strong>Site Domains<\/strong> Router Mode\r\n<ul class=\"wp-block-list\">\r\n<li>The default mode that Local runs. In this mode, Local will start a &#8220;router&#8221; that listens on port 80 and directs traffic to the individual sites that Local manages. The domain for each site will look something like <code>example.local<\/code><\/li>\r\n<\/ul>\r\n<\/li>\r\n\r\n\r\n\r\n<li><strong>localhost<\/strong> Router Mode\r\n<ul class=\"wp-block-list\">\r\n<li>This fallback mode doesn&#8217;t start the Local router and instead, each site is reached directly using a dedicated port on the computer. Using this mode means that the domain will look something like <code>localhost:10005<\/code><\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-fcf89f05a8bbc4f48ca7737810bdcb23\" style=\"color:#000000\"><strong>How Local Works<\/strong><\/h2>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Ok, that&#8217;s a lot of jargon, so if you&#8217;re confused, it might help to zoom out a bit and understand how the different Local parts work.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">In general, the software that serves up web pages &#8220;listens&#8221; for requests and then generates a &#8220;response&#8221; for that request. The actual location that these pieces of software listen to is called a port. For example, the default port for requests made over HTTP is port <code>80<\/code>, while requests made over HTTPS is port <code>443<\/code>.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Since only one piece of software can listen to a port at one time, Local has to figure out a way to serve multiple sites from the same HTTP port (port <code>80<\/code>).<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Local does this by doing two things:<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li>Each site that Local manages is given a random port number to listen to, for example, <code>10005<\/code>. Those sites can be accessed directly by appending the port to <code>localhost<\/code>, which looks like: <code>localhost:10005<\/code>.<\/li>\r\n\r\n\r\n\r\n<li>A &#8220;router&#8221; is created and is listening on port <code>80<\/code>. This router is responsible for translating a meaningful domain like <code>example.local<\/code> into the actual site listening on a specific port: ie, <code>localhost:10005<\/code>.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">When using &#8220;Site Domains&#8221; router mode, the browser connects to port 80 and Local&#8217;s router then connects to the appropriate port for each individual site.<\/p>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full is-style-drop-shadow\"><img decoding=\"async\" width=\"1000\" height=\"500\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-9.png\" alt=\"\" class=\"wp-image-2165\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-9.png 1000w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-9-300x150.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-9-768x384.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">When using <code>localhost<\/code> router mode, the browser connects directly to the port that each site is listening on. This allows another process to listen on port 80, but it also means some diminished functionality when interacting with those sites.<\/p>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1000\" height=\"500\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-10.png\" alt=\"\" class=\"wp-image-2166\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-10.png 1000w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-10-300x150.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-10-768x384.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\r\n\r\n\r\n\r\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-aa24f356f4ade9336080c393d0c44f8a\" style=\"color:#000000\"><strong>What Happens When Local Can&#8217;t Start The Router?<\/strong><\/h2>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Hopefully, that additional context helps visualize how Local is configured. As you might imagine, things can break when the router isn&#8217;t able to start \u2013 the most obvious thing that breaks is that you can&#8217;t use meaningful domains like <code>example.local<\/code>. Instead, you would have to remember the port number for each site.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">In most cases, Local can&#8217;t start the router because there is <em>something<\/em> already occupying port <code>80<\/code>. There are only two options to get things working:<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li>Set Local to use <code>localhost<\/code> Router Mode.<\/li>\r\n\r\n\r\n\r\n<li>Stop whatever is already listening on port 80 and restart Local.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-775c8d6f762953045ff3739d179a2ca4\" style=\"color:#000000\"><strong>Using <code>localhost<\/code> Router Mode<\/strong><\/h2>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Of the two modes that Local can use, setting the router mode to <code>localhost<\/code> is the easiest and allows Local to run while other applications are using the default HTTP port of <code>80<\/code>. If you go this route, there are some limitations when using <code>localhost<\/code> router mode:<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li><strong>Sites can&#8217;t use HTTPS<\/strong>. Because Local can&#8217;t manage the <code>localhost<\/code> SSL certificate, there&#8217;s no way for Local to make the sites accessible over HTTPS.<\/li>\r\n\r\n\r\n\r\n<li><strong>Sites can&#8217;t use Live Links<\/strong>. The router handles part of the magic of using live links.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Selecting the Router Mode from the &#8220;Advanced&#8221; section of the Preferences screen.<\/p>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-11.png\" alt=\"\" class=\"wp-image-2168\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-11.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-11-300x206.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-11-768x527.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">When in <code>localhost<\/code> Router Mode, the Site Host will have <code>localhost<\/code> and the port number for the site.<\/p>\r\n\r\n\r\n\r\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-12.png\" alt=\"\" class=\"wp-image-2169\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-12.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-12-300x206.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2023\/07\/image-12-768x527.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\r\n\r\n\r\n\r\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-63a7a21b0f52032aef45c0cfd8525310\" style=\"color:#000000\"><strong>Stopping Whatever Is Listening On Port 80<\/strong><\/h2>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">If you want to use all of the features that Local offers, then running in the default &#8220;Site Domains&#8221; router mode is required. In most cases, this is seamless, but if you are unsure about what piece of software is already listening on port 80, it can be challenging to zero in on where the conflict is.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-d78933c0befe007386f34dfbf56509ee\" style=\"color:#000000\"><strong>Mac<\/strong><\/h3>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">The quickest way to zero in on what is listening on port <code>80<\/code> is to open a terminal and issue this command, which will prompt you for your computer password.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>sudo lsof -i:80; sudo lsof -tnP -i:80 | xargs -n 1 ps -p<\/code><\/pre>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">If you&#8217;re curious about what this command is doing, it&#8217;s basically:<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li>Listing all the &#8220;open files&#8221; on port 80<\/li>\r\n\r\n\r\n\r\n<li>Listing more details about the process that&#8217;s running on port 80<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">With that additional info, you should be able to shut down that application gracefully, but if you need to kill that process forcefully, you can do so from within a terminal:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>kill &lt;process-id&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Under Windows, finding those processes that are listening on Port 80 can be a little more tricky and might need to do some examining with the Task Manager. <\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">One thing that can help is to use <code>cmd.exe<\/code> to run the following commands to help drill down to the actual processes that are listening on port 80.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Note: make sure to replace <code>&lt;process-id&gt;<\/code> with whatever process you found in the first command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>netstat -nao | find \"80\"\r\ntasklist \/v \/fo list \/fi \"pid eq &lt;process-id&gt;\"<\/code><\/pre>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Hopefully, that points you to the application that&#8217;s listening, as well as give you enough info to investigate further. <\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">As an example, here are a couple of screenshots of investigating and disabling the built-in IIS server that is enabled by default for some versions of Windows.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" width=\"1024\" height=\"667\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80-1024x667.png\" alt=\"\" class=\"wp-image-423\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80-1024x667.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80-300x195.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80-768x500.png 768w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80-1536x1001.png 1536w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-finding-windows-port-80.png 1549w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A screenshot showing how to use the output from the <code>netstat<\/code> command to zero in on the actual process in the Task List. From there, additional info can be found by right-clicking on the process and selecting &#8220;Properties.&#8221;<\/figcaption><\/figure>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-windows-built-in-server.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" width=\"1024\" height=\"582\" src=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-windows-built-in-server-1024x582.png\" alt=\"\" class=\"wp-image-425\" srcset=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-windows-built-in-server-1024x582.png 1024w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-windows-built-in-server-300x171.png 300w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-windows-built-in-server-768x437.png 768w, https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-windows-built-in-server.png 1126w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Using the information from the previous image, we can do an internet search for <code>ntoskrnl windows port 80<\/code>. This lead me to disable the built-in IIS server from within Windows Features.<\/figcaption><\/figure>\r\n\r\n\r\n\r\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"changing-router-mode\">Changing Router Mode<\/h2>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">If the router mode is changed, some additional steps need to happen for the site to work with the new Router Mode.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">Local will occasionally check to see if the domain within the database matches what it thinks the domain should be. If those are different, it will prompt you to &#8220;fix it&#8221;. In the case of switching to <code>localhost<\/code> router mode, Local will search for <code>example.local<\/code> and replace it with the appropriate port number, something like <code>localhost:10005<\/code>.<\/p>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">A similar process happens when switching back to &#8220;Site Domain&#8221; router mode.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-video\"><video height=\"1354\" style=\"aspect-ratio: 2002 \/ 1354;\" width=\"2002\" controls src=\"https:\/\/localwp.com\/wp-content\/uploads\/2020\/12\/router-mode-changing-settings-and-fixit.mp4\"><\/video><figcaption class=\"wp-element-caption\">A screencast that walks through changing the Router Mode and then clicking the &#8220;Fix It&#8221; button to update the domain within the database.<\/figcaption><\/figure>\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>Router Mode is Local&#8217;s way of offering the best offline development experience possible while still &#8220;playing nice&#8221; with other, similar development applications.<\/p>\n","protected":false},"author":49,"parent":352,"menu_order":13,"template":"","tags":[43],"helpcategories":[5],"class_list":["post-139","help","type-help","status-publish","hentry","tag-advanced","helpcategories-advanced"],"acf":{"help_keywords":""},"_links":{"self":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc"}],"about":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/types\/help"}],"author":[{"embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/users\/49"}],"version-history":[{"count":0,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/139\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/help-doc\/352"}],"wp:attachment":[{"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/tags?post=139"},{"taxonomy":"helpcategories","embeddable":true,"href":"https:\/\/localwp.com\/wp-json\/wp\/v2\/helpcategories?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}