KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Checking for open ports in 4D v11 SQL
PRODUCT: 4D Server | VERSION: 11 | PLATFORM: Mac & Win
Published On: February 26, 2010

It can be interesting, for troubleshooting purposes, to check and make sure that 4D Server's ports are actually open and listening for connections. It is also possible to check currently open ports for any existing 4D Remote connections. Here is how to check the open ports for 4D Server:

Checking Ports on Windows

On Windows the command 'netstat' is used to check 4D's ports. Here is an example:

netstat -b -a -p TCP


  • The -b option causes 'netstat' to display the executable name that opened the port.
  • The -a option causes 'netstat' to display all connections but, more importantly, listenting ports.
  • The -p option is used to filter for a specific protocol. In this case I only care about TCP ports.

Here is an example of the output (note that the output has been edited to only show 4D Server ports beacuse the output of 'netstat' can be quite verbose):

Active Connections

Proto Local Address Foreign Address State PID
TCP josh-dell-xp:http josh-dell-xp.private.4d.com:0 LISTENING 3908
[4D Server.exe]

TCP josh-dell-xp:1919 josh-dell-xp.private.4d.com:0 LISTENING 3908
[4D Server.exe]

TCP josh-dell-xp:19813 josh-dell-xp.private.4d.com:0 LISTENING 3908
[4D Server.exe]

TCP josh-dell-xp:19814 josh-dell-xp.private.4d.com:0 LISTENING 3908
[4D Server.exe]


As you can see, the following ports are open and listening:
  • http (aka port 80)
  • 1919 (aka the SQL port)
  • 19813 (aka the Application Server port)
  • 19814 (aka the DB4D port)

For more information about 'netstat', open a Command Prompt and type:

netstat /?

Checking Ports on Mac OS X

On Mac OS X the command 'lsof' is used to check 4D's ports. Here is an example:

sudo lsof -i -P | grep '4D'


In this example the following options are used:

  • The 'sudo' command is used to execute 'lsof' so that it will have sufficient rights to get the data.

  • The -i option causes 'lsof' to only display "internet" files. The 'lsof' command can actually list all open files on the system or, said another way, everything in a Unix-based system is a "file". In this case we are only interested in files of the internet type.
  • The -P option causes 'lsof' to print the actual port numbers instead of the names (for known ports, like "http").
  • Finally the results are filtered, using 'grep', so that only the ports for 4D are listed.

Here is an example of the output:

4D\x20Ser 3011 jfletcher 27u IPv4 0x5b7266c 0t0 TCP *:19814 (LISTEN)
4D\x20Ser 3011 jfletcher 28u IPv4 0x5ae5270 0t0 TCP *:19812 (LISTEN)
4D\x20Ser 3011 jfletcher 29u IPv4 0x5b64e64 0t0 TCP *:19813 (LISTEN)
4D\x20Ser 3011 jfletcher 30u IPv4 0x3b89f40 0t0 UDP *:19813


As you can see, the following ports are open and listening:
  • 19812 (aka the SQL port)
  • 19813 (aka the Application Server port)
  • 19814 (aka the DB4D port)

For more information about 'lsof', open a Terminal and type:

man lsof

See Also:
Commented by James Rowe on March 17, 2011 at 10:15 AM
Important note: all Mac OS X terminal commands are by default is case sensitive. In this example grep '4D' is not the same as grep '4d'; the 'D' was intentionally capitalized. The -i option can be used to make grep case insensitive.