Knowing which PORT is using by which APPLICATION

April 20, 2009 07:49 by Ramana

Recently for a client need to install our SilverLight application on his laptop for demo over GotoMeeting. The laptop is having Vista 64 bit Windows OS. After installing IIS 7 on it, the webserver's Default Website was not starting. So checked everything - Services, Installed Apps in Programs & Features etc, to see whether Apache or Tomcat or any other webserver is running and blocking 80 port. But couldn't see any of those applications.

Then started hunting to know who is blocking 80 port on that machine. Did little googling and found following 2 commands to know which app is listening to the 80 port.

Through these commands you can know easily which application is listening to a particular port. As well you can see all ports that are exposed and applications that are using them. This is a 2 step process. First we will see ,what are the ports that are listening by different Process Ids. Next using that PID we will get the Application name.

To know the listening ports on your machine type the following command in CMD prompt

netstat -ano | find /i "listening"

Fist column will show you the protocol TCP or UDP, next IP & PORT numbers of Source, next IP & PORT numbers of Destination machine, next State (that we needed to filter the list), and finally the Process Id (PID).

From the last column we will take the Process Id and find the Application of it.

So for that lets Google and download a small application named PUList. The Windows 2000 Resource Kit Tool needs you to go through Genuine OS check, and then you can download the PULIST.EXE. After downloading & installing PUList, navigate to the installed directory in CMD prompt. Run the following command in there,

pulist |find /I "6372"

or just

pulist 

will list all the processes that are running.

Finally we found that Skype is using the port 80. So after exiting it the IIS Default website started working. 


Apache Windows .htaccess - Password Protect Parent and Allow Sub Directory

August 6, 2008 08:10 by Ramana

To protect a directory in Apache web server, you need to create two files “.htaccess” and “.htpasswd”. “.htaccess” has to be placed under your designated directory. Once you place “.htaccess” under a directory, all its sub directories will inherit its parent properties. Each folder can have its own “.htaccess” file, if it needs to override or extend its parents’ properties.

“.htpasswd” is for storing Usernames and Passwords. It can be placed in the each directory or at a common place to maintain all logins at one place.

In “.htaccess” file you have to specify the path to “.htpasswd”. To protect a web folder the contents in “.htaccess” will be

AuthUserFile C:\wamp\passwords\.htpasswd
AuthName "This is Hasten secret area"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

kick it on DotNetKicks.com  

To create “.htpasswd” file with Usernames and Passwords in it, you can find a utility “htpasswd.exe” under “<Apache’s installation directory>/bin” or you can create them online using Dave Child’s page.

In command prompt navigate to the above directory and type below command
htpasswd .htpasswd a-user-name

It creates “.htpasswd” file under “<Apache’s installation directory>/bin” itself. Repeat the same command to add more usernames. Cut the file from there and paste it under desired place as mentioned in the “.htaccess” – “AuthUserFile”.

If you create with Dave Child’s page, paste the text in notepad and save file as “.htpasswd” in desired directory as mentioned in the “.htaccess” – “AuthUserFile”.

Up to now we have seen password protecting a parent folder. Now by placing the following “.htaccess” file in sub folder will make it unprotected. The contents in “.htaccess” will be

Allow from all
Satisfy Any

That’s it! It’s simple!

Are you facing any problem, let’s do discuss here, post your comment.
Let me know your feedback.