I'd like to write the code for a website on one pc and see the results in a browser on another pc in my local network.

For calling the skewer script in html, I replaced localhost with the local ip of pc1 – <script src="*pc1.ip*:8080/skewer"></script>.

But simple-httpd seems to only serve the site (and skewer script) on localhost, when I try to access *pc1.ip*:8080 via pc2 I get ERR_CONNECTION_REFUSED.

Other simple http serve solutions (i.e. python -m http.server 8080) are accessable via local network, however they don't "interact" with skewer.

Is there a way to access simple-httpd via non-localhost? Or maybe a way to connect skewer and another serving solution?

/EDIT1 - after DoMiNeLa10♦'s comment/
Tried to set httpd-host to pc1.ip – now I can access the page via pc2 – but no skewer functionality (no autorefresh on save, no skewer-eval-*,…).

/EDIT2 - again thanks to DoMiNeLa10♦'s comment/
Tried adding a domain name for pc1 ("pc1" ^^) in /etc/hosts on both pc and changed to <script src="http://pc1:8080/skewer"></script> in html. No luck –> ERR_CONNECTION_REFUSED on pc2

  • 1
    This seems to be related to the variable httpd-host, which is passed to make-network-process, which compares its value against the host that's requested. You can try commenting out the line that provides it to that function in httpd-start. That might be your culprit, and the whole issue might be worth reporting, as such a feature can be quite useful. – DoMiNeLa10 Oct 29 at 20:46
  • Thanks for hint! Tried to set httpd-host to pc1.ip – now I can access the page via pc2 – but no "skewer functionality" on both pc… – kai-dj Oct 29 at 20:55
  • As a quick hack you can add entries with the same domain name in /etc/hosts on both machines. Just make sure the IP address points to the right machine in both cases, they will end up being different. – DoMiNeLa10 Oct 29 at 21:00
  • Like so: /etc/hosts on pc1 add line 127.0.0.1 pc1/etc/hosts on pc2 add line 192.168.2.100 pc1 – set httpd-host to pc1 and <script src="pc1:8080/skewer"></script>? (ERR_CONNECTION_REFUSED when I try to access pc1:8080 via pc2 – no skewer functionality on pc1…) – kai-dj Oct 29 at 21:14
  • Try adding the protocol (http://) before the link, I have a feeling browsers are picky about URLs like this if you don't give them the protocol explicitly. – DoMiNeLa10 Oct 29 at 22:32
up vote 1 down vote accepted
+50

An alternative to setting httpd-host to a hostname is to set it to an IP. You can use 0.0.0.0 to bind to all local IP addresses. Try (setq httpd-host "0.0.0.0") (it works for me).

  • Yey - that works. Just adding: in html skewer must still be loaded via <script src="http://pc1:8888/skewer"></script> – kai-dj Nov 9 at 10:11
  • …and even without hosts entry at all and just the IP – meaning skewer can be used in different local networks with zero configuration needed on viewers side. Could become very handy =) – kai-dj Nov 9 at 10:16

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.