How to determine what programs are bound to what ports on Windows

Standard

Sometimes you get the need to know what programs are listening or bound to a particular port on Windows. For me, the most frequent scenario is this: I install WampServer on a PC hoping  to use Apache as a web server only to discover that Apache cannot start.

After wondering (a little stupidly at times) why, I resort to check Apache’s logs and discover that the service isn’t starting because it can’t bind to port 80. Implication, some other program got there first! (Well, not really. Just that the other program was installed first)

Most times, I’d just open up the Apache server config file and change the port which it binds to. Some other times, I’d need to identify the offending program and change the port. At a point in the past, if Skype was installed on Windows, you’d need to instruct Skype to use another port (after maybe spending a whole afternoon wondering why Apache won’t start) as it listens for incoming connections on port 80.

Then comes the hard part: How do I know what program is listening on what port?

It turns out it’s fairly easy. As this StackOverflow Answer points out, running this command:  C:\> netstat -a -b  should do. More from the answer:

(add -n to stop it trying to resolve hostnames, which will make it a lot faster)

-a Displays all connections and listening ports.

-b Displays the executable involved in creating each connection or listening port. In some cases well-known executables host multiple independent components, and in these cases the sequence of components involved in creating the connection or listening port is displayed. In this case the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions. -n Displays addresses and port numbers in numerical form.

Running this command with the -b option might require administrative privileges as I discovered on my computer.

To get the Process Identified (PID) of the of the process making use of any port, execute the command with the -o option like this:  C:\>netstat -a -o or like this  C:\>netstat -ao

This would show you the PID which you can use to look for the “offending” program or process in the Windows Task Manager.

If you’d rather use a GUI (or you’re not that much of a command-line person), you could use these tools which I found during the course of my search:

  • TCPView – https://technet.microsoft.com/en-us/sysinternals/bb897437
  • CurrPorts by NirSoft – http://www.nirsoft.net/utils/cports.html

Setting Up Email with Zoho, Cloudflare and DigitalOcean

Standard

Just over a year ago, I (as Co-Founder and CTO of Football411 Online) decided it was time for us to move to our own server so we paid for and spun up a new droplet on DigitalOcean. Prior to the move, I had created a few email accounts on the shared hosting platform and back then I wasn’t worried about losing the addresses because I was like the only one using mine.

Long story short, we no longer had @football411.net emails and for a while, nobody cared. Fast forward to last night and my partner informed me that one of our new editors badly needed an official email address to be setup and I thought: oh crap! Here we go again. I told him I’d sort it out in the morning and so I started looking at my options.

At first, I thought we should just add mail server capability to our DigitalOcean droplet but this tutorial from the good folks at DO told me why that was a sort of not-too-good idea. They were also kind enough to provide alternatives in the same post and bargain-hunter that I am, I quickly found out that we could get 10 email accounts with 5GB storage for free with Zoho.

Zoho-Mail-Pricing

DigitalOcean also provided a tutorial on how to go about setting up Zoho with a custom domain. In our case, we’d already started using Cloudflare for DNS management so I had to do the configuration on Cloudflare, rather than on DigitalOcean. In a way, it made it easier.

The steps involved are simple:

  • Signed up for a Zoho Mail Account
  • Complete the Domain Verification Step
  • Create Email accounts and Groups
  • And the most important step so you can actually receive mails. You need to Add MX Records on your domain. To do this, open DNS settings for the appropriate domain on Cloudflare. Add an MX Record as shown in the Screenshot below:

Create MX Record on Cloudflare

If everything is set up as instructed, you should be able to send mails to the addresses you created. To read your emails, just go to http://mail.zoho.com.