OK, so I’ve been messing around with a program called Mister House, designed to control appliances and such from your computer via a web interface (hey, I’m unemployed, all I’ve got is time…). The program itself acts as a rudimentary web server for the interface in addition to actually controlling whatever devices you have set up (I don’t have any devices yet, BTW – I’m just mucking about with the stuff you can do with just the PC).
Out of the box, the program should serve up the web interface when you point your browser to localhost (127.0.0.1). But it doesn’t do that for me. Whenever I try to connect to localhost, either by name or by IP number (yes, “localhost” is properly named in my hosts file), I get a “connection refused” error.
On the other hand, I’m on the web via cable modem. When I pull up winipcfg to get my current IP and use that in the browser, everything works fine.
My question is, why? I admit to knowing almost nothing about how this stuff works. As I understand it, localhost and my current IP should both point back to the same machine, i.e., my desktop PC. Why does one work and not the other?
I’d like to have localhost working so I don’t have to look up my current IP every time. My ISP doesn’t switch my IP very often, but it does happen. It’d be much easier to just use localhost.
I’m running a PIII 866 with a cable modem on Windows 98SE. Let me know if you need any additional information.
Can you configure what interface the web server binds to?
While I don’t know much about windows, 127.0.0.1 and your external IP are usually on different interfaces (lo and ethernet) and it is possible that the applications just uses the ethernet interface.
I went throug the INI for Misterhouse and this is the only part I think relates to the stuff we’re talking about:
@ http_port:
@ Use 80 if you want to use the normal web port (i.e. http://localhost)
@ If using something other than 80 (because you already have a web server
@ running), add :port to url (e.g. http://localhost:8080)
@ If you are having problems with this, you may want to try
@ a different port, in case a different service is using this port.
@ Normally leave http_address blank, unless your box has multiple ip cards/addresses.
http_port = 8080
http_address =
@ If the mh http server pauses longer than this time (in seconds), a message will be logged.
http_pause_time = 2
@ This parm will turn on/off the web browser keyboard control for
@ the web menu pages. Note, these javascript controls only work on
@ IE and NS 6+
html_menu_keys = 1
@ The proxy parm is needed if your use a proxy to get to the internet.
@ Used get get_url (if get_url parm is set to useragent) and get_tv_grid
@ This overrides the env parm HTTP_PROXY
proxy =
@ http_server:
@ Used when generating urls that point to your server (e.g. get_tv_grid).
http_server = localhost
@ http_fork:
@ Set to 1 to enable forking when serving large web pages.
@ This helps avoid mh pauses, especially with remote/slow web clients.
@ If left blank, it defaults to off for win95 and 98,
@ on for nt, 2k, xp, and unix.
http_fork =
The full mh.ini is pretty big; you can look at it by downloading the program and extracting that particular file.
I haven’t changed any of the defaults, except to make the port 80 so I don’t have to add that to the URL (I’ve tried this with the default setting of port 8080, so I know that isn’t it).
The author of the program says it should work with localhost out of the box.
What do you mean by binding the server to an interface? Like I said, I’m stumbling my way through this – I know very little about IP addressing. In some ways, I’m less interested in getting this particular program to work and more interested in understanding WHY it isn’t working. Please educate me.
Dewey, odds are that if you want it to work on localhost you will have to explicitly put localhost (or 127.0.0.1) in the configuration where it says http_address.
The author probably developed the software on on Windows 2000 or Windows XP. You’re using Windows 98SE. Windows 98SE has a different networking layer than Windows 2000/XP, and it’s probably the case that he hasn’t fully tested the program on 98.
KellyM: That works! OK, so now the followup question: is it possible to have the program respond to both localhost and the ISP-generated IP address? Your solution solves the problem with localhost, but prevents the server from responding when the ISP-generated IP is used – it basically reverses the results described in the OP. Is there any way around this?
I’m more interested in the “whys” than I am in the specifics of this particular program. What exactly is going on behind the scenes and why can’t the server handle both addresses?
Well, assuming you’re on a permanent ISP connection, one possibility is to get a cheap router which sits between you and the ISP, and use a static IP address for your windows machine. Seeing as how you seem to have multiple machines (you want to access the web interface from a different machine), this would be a good thing anyway, so you can have everybody have simultaneous internet access.
Or perhaps you meant that you want to get to the web interface from somewhere else on the internet like work. In that case, I don’t know a solution. You can use DDNS to always find your machine when the IP address changes, but it sounds like there’s something funky between Win98 and MisterHouse that mandates a predefined IP address for it’s usage. Which would be unbelievably lame, so I suspect there’s a solution, but I don’t know it.
BTW, this MisterHouse looks interesting. Please post back if you like it or not.
Will do. The latter scenario is the situation I’m in – I think it’d be cool to be able to adjust the thermostat from work (er… when I find employment, anyway). But when I’m at home I’d just as soon use localhost and save the internet DNS lookup.
But I’m getting ahead of myself. I haven’t even bought an X10 device yet – I’m just goofing around with the time and date stuff, and the voice stuff. I’ll buy a device and see if I can get it to turn a lamp on and off before I start messing with my HVAC system.
Dewey, try setting http_address to 0.0.0.0 or 255.255.255.255. That may force the program to listen on all interfaces.
Basically, your computer has a few different IP addresses, as you know, but what might not be obvious is that each address belongs to a different network interface and is very separate from the others. You have a loopback interface (localhost) with the IP address 127.0.0.1, an ethernet interface for your cable modem with a different address, and possibly other interfaces (dialup, etc.) with yet more addresses.
When a program wants to listen for connections, it creates a socket, “binds” the local end of the socket to an IP address and port number, and tells the OS it wants to start listening on that socket. Usually, programs set the IP address to INADDR_ANY (0.0.0.0), which the OS interprets as “listen to this port on all interfaces”… but if the program explicitly sets an address, it only answers connections coming through the interface that corresponds to that address. (This is useful for e.g. virtual host web servers, which may have several different IP addresses, and different web servers listening on each one.)
I’d expect Mister House to bind to INADDR_ANY when you leave ‘http_address’ blank, but instead, it might be guessing which interface connects to the Internet and only binding to that one. There are some situations where that’s a good thing, but this doesn’t seem like one of them.
Mr2001: I bow to your networking kung-fu. Setting it to 0.0.0.0 worked perfectly – both IPs work now. Are there any disadvantages to this setting?
And thanks for the explanation, which I mostly understand (no small feat on your part). Is there anything you’d recommend I read to better understand this stuff?
Dewey: The only disadvantage is that anyone who knows your IP address can access this program over the internet. Make sure you have a good password, and keep an eye out for any updates in case they discover a security hole.
The only resources I could find are oriented toward programmers. You might want to check out an introductory networking book, like Networking for Dummies or a college text.
Mr2001: Thought you’d like to know I contacted the author of the program and let him know your solution. He was quite impressed and is adding it to the explanatory text in the .ini file. Mister House users everywhere thank you.