Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've written a simple program that runs on a non-server mac. When I visit http://localhost:39600/test in a web browser, it gives me the correct response: "Here's my response!".

I then move this java file to a webserver Mac OS X Snow Leopard managed with Server Admin, compile it, run it on port 39600, visit http://localhost:39600/test in the webserver's internet browser. It gives the correct response. But when I visit http://webserveraddress:39600/test it doesn't respond at all. I know it's probably something with server admin and the firewall, but how do I open up port 39600 to outside requests through Server Admin?

Here's the simple, standard java class, though I think it's more an issue with Server Admin.

package server;


public class Server {

    private static final int SERVER_PORT_NUMBER = 39600;
    private static final int MAX_WAITING_CONNECTIONS = 10;

    public static void main(String[] args) {
        new Server().run();

    private Server(){

    private HttpServer server;

    private void run(){
        server.createContext("/test", testHandler);

    private HttpHandler testHandler = new HttpHandler(){

        public void handle(HttpExchange t) throws IOException {
            //TODO read request body

            t.sendResponseHeaders(200, 0);  //all ok!
            OutputStream os = t.getResponseBody();
            os.write("Here's my response!".getBytes());


    private void configure(){
        try {
            server = HttpServer.create(new InetSocketAddress(SERVER_PORT_NUMBER),
        catch (IOException e) {
            System.out.println("Could not create HTTP server: " + e.getMessage());

        server.setExecutor(null); // use the default executor
share|improve this question

This is most likely caused by a closed port on the router, although it could be a firewall on the web-server. You need to open up port 39600 on the router for the server's network - this is known as port-forwarding.

share|improve this answer
This server isn't behind a router. It has a static IP address. I'm looking for specific Server Admin help. It's the software that manages everything to do with the server on Mac OS X 10.6.8. I just don't know how to allow that port to be open. – ejsuncy Aug 10 '13 at 18:12
up vote 0 down vote accepted

It turns out that Server Admin doesn't manage specific ports. The GUI for the Snow Leopard firewall only lets you open specific applications (and thereby their associated port numbers). To open a specific port, you have to dig in to Terminal and type sudo ipfw add <rulenumber> allow tcp from any to any dst-port <portnum> where <rulenumber> is between 00001 and 65535 and <portnum> is as well (there are reserved port can see which ones are with sudo ipfw list.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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