Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

What is the easiest way to check if port 3306 on my localhost is being blocked?

share|improve this question
1  
Just to clarify, do you mean blocked, as in blocked by a firewall or gateway, or do you mean already in use by something else? –  squillman Jun 16 '09 at 14:34

5 Answers 5

up vote 53 down vote accepted

Since you are on the Windows machine, these things can be done,

  • Execute the following command and look for a ":3306" listener (you did not mention UDP/TCP). This will confirm there is something running on the port.

    netstat -a -n

  • After this, if you are expecting incoming connections on this port and feel that the firewall may be blocking them, you could start windows firewall logging and check the logs for dropped connections

    • Go to the Windows Firewall, Advanced settings
    • Click on the Settings button next to "Local Area Connection"
    • Select "Log dropped packets"
    • Look at the log file location (if not present define one)
    • Click OK
    • Now, when the connection attempt is made (assuming you know when this is done), look at the log file for a drop on port 3306.
    • If this is seen, you will want to add an exception for this port.
  • There is one more command to check the firewall state
    (Update for Windows 7 users -- as referred by Nick below -- use netsh advfirewall firewall)

    netsh firewall show state

    • this will list the blocked ports as well as active listening ports with application associations
  • This command will dump the Windows firewall configuration detail

    netsh firewall show config


If you have an active block (incoming connections are being dropped by firewall) after you start logging, you should see that in the log.

If you are running an application/service that is listening on 3306, the firewall config should show it to be Enabled. If this is not seen, you have probably missed adding an exception with the firewall to allow this app/service.

Finally, port 3306 is typically used for MySQL. So, I presume you are running MySQL server on this windows machine. You should therefore see a listener for 3306 accepting incoming connections. If you do not see that, you need to work with your application (MySQL) to get that started first.

share|improve this answer
2  
+1 for great details –  Sage Jun 16 '09 at 15:39
1  
Starting with Windows Vista the "netsh firewall" command is deprecated. It recommends you use "netsh advfirewall firewall" instead and references article go.microsoft.com/fwlink/?linkid=121488 –  Nick DeVore May 18 '11 at 15:31
    
To parse output at the command line, add |find "3306" to the command, e.g. C:\Windows\System32>netstat -an |find "3306" –  Cees Timmerman Jul 5 '13 at 8:20

If you can telnet to the port from the local machine (using the external IP address), but not from another machine - then it is being blocked somewhere between.

Note that a firewall on your local machine could prevent even the first action.

share|improve this answer

If you've got somthing listening on that port, just telnet to it from another machine. If not, set up a netcat listener there. If you're publically facing the internet, with no NAT/Firewall in the way GRC.com has a tool called ShieldsUP that can check for you.

share|improve this answer

If you need to test if a port is open from the outside to a specific computer, Port Detective can take care of that for you. 3306 isn't one of its default ports to test, but you can add custom ports for it. Remember to shut down any software that might be using that port before running the test though, as it needs to have the port available for use.

If the test fails, you'll need to ensure that any NAT routing is forwarding the port to your computer, and that there is no firewall getting in the way.

share|improve this answer

The Audit My PC Firewall test allows you to test a specific port or a range of ports from an external source.

share|improve this answer

Your Answer

 
discard

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.