1

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

kai-dj
  • 427
  • 2
  • 15
  • 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. –  Oct 29 '18 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 '18 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. –  Oct 29 '18 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 ``? (`ERR_CONNECTION_REFUSED` when I try to access pc1:8080 via pc2 – no skewer functionality on pc1…) – kai-dj Oct 29 '18 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. –  Oct 29 '18 at 22:32
  • It's not that – chromium seems to "assume" http anyway. (Of cource I tried nevertheless – no difference) – kai-dj Oct 29 '18 at 23:36
  • …I have to correct my "no skewer functionality on pc1"-comment before. It works when html is changed accordingly – still no luck via pc2 – kai-dj Oct 30 '18 at 11:43

1 Answers1

2

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).

ebpa
  • 7,319
  • 26
  • 53
  • Yey - that works. Just adding: in html skewer must still be loaded via `` – kai-dj Nov 09 '18 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 09 '18 at 10:16