What does it mean for an address to be invalid in context (error code OS 10049)?

Pops asked:

I’m trying to start an instance of Apache 2.2 server with a fairly-close-to-standard configuration file. I made one small change because I want Apache to serve a single XML file separately from everything else it does, purely for testing on my local machine. The change is that I inserted this into httpd.conf:

# Based on http://httpd.apache.org/docs/2.2/vhosts/examples.html



DocumentRoot "C:\foo\bar"
ServerName www.MyCompanyMyProjectFooBarTestURL.com

Attempting to start Apache resulted in this:

(OS 10049)The requested address is not valid in its context. : make_sock: could not bind to address
no listening sockets available, shutting down
Unable to open logs

No instances of Apache are running. Nothing is using port 85 (or 80 or 8080). There’s nothing special about; I just figured that was an IP that wouldn’t interfere with anything.

What does this error mean, and how can I resolve it?

My answer:

Since nobody has yet explained what is going on:

Apache cannot bind to the local IP address you gave, because the computer is not configured with that IP address.

There are a couple of ways to solve this:

  1. You can Listen to an IP address that the computer actually has. But keep in mind that specifying an IP address restricts incoming connections, and only other hosts which can reach that address will be able to access the server, and only via that address. For a production web server on the Internet, this is almost always not what you want, so…

  2. Don’t specify an IP address in the Listen directive. Apache will then listen to all interfaces for incoming connections. If it doesn’t matter where the connections come from, such as a publicly accessible web server or one which is properly firewalled, then this is the simplest solution.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.