<p>I am relearning golang but more specifically I don't know how http works in general. On all the tutorials for http in golang they use http.ListenAndServe(":8000", nil) to start the http server but they tell you to view the result at http://localhost:8000. How would I view it on the local network as 192.168.1.8:8000 if that was my computers ip on the network? Do I have to set up the http server in golang any differently?</p>
<hr/>**评论:**<br/><br/>nowayno: <pre><p>Not sure I understand the question. To access the web server from another app on the same computer, you use localhost:8000 (or 127.0.0.1:8000 should work too), and to access the web server from another computer you'd use the IP address like 192.168.1.8:8000. You don't have to do anything special.</p></pre>likehowdoi: <pre><p>If I understand your question correctly, you have a development server on your LAN, but are using a different computer to log in and develop. </p>
<p>I believe it's your firewall preventing other LAN computers (and remote alike) from connecting to port 8000. Check this first before anything. It shouldn't effect anything if you are using the same machine for everything. But it sounds like you want to view the page on a different machine.</p>
<p>Just open a browser like firefox and open http://localhost:8000 and then on a different pc on the LAN visit <a href="http://192.168.1.8:8000" rel="nofollow">http://192.168.1.8:8000</a></p>
<p>if you are logged in SSH, just use curl or w3m to view your localhost site and see if it works. If you are trying to use your browser from a different machine you would have to open port 8000 on the server end.</p>
<p>On a local network you would have to open firewall port as well. If you don't have apache or nginx (or another server) already on port 80, you can probably just use 80. Then you can type <a href="http://192.168.1.8" rel="nofollow">http://192.168.1.8</a> in a browser on the LAN. </p>
<p>There are many request types, you probably have heard of POST, GET, there are others as well. When you visit a web site it is a GET request, when you "post" or "upload", it is a POST request. (generally.)</p>
<p>Optional: Try adding a line in your /etc/hosts file to bypass DNS and use your own fun domain names:</p>
<p>192.168.1.8 funtime.com funtime</p></pre>
![](https://static.golangjob.cn/static/img/banner.png)