How can I change the project port number in Visual Studio 2013 ?
I'm using ASP.Net and I need to change the port number while debugging in Visual Studio 2013.

- 3,638
- 12
- 53
- 87
9 Answers
There are two project types in VS for ASP.NET projects:
Web Application Projects (which notably have a .csproj or .vbproj file to store these settings) have a Properties node under the project. On the Web tab, you can configure the Project URL (assuming IIS Express or IIS) to use whatever port you want, and just click the Create Virtual Directory button. These settings are saved to the project file:
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<DevelopmentServerPort>10531</DevelopmentServerPort>
...
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
Web Site Projects are different. They don't have a .*proj file to store settings in; instead, the settings are set in the solution file. In VS2013, the settings look something like this:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite1(1)", "http://localhost:10528", "{401397AC-86F6-4661-A71B-67B4F8A3A92F}"
ProjectSection(WebsiteProperties) = preProject
UseIISExpress = "true"
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.5"
...
SlnRelativePath = "..\..\WebSites\WebSite1\"
DefaultWebSiteLanguage = "Visual Basic"
EndProjectSection
EndProject
Because the project is identified by the URL (including port), there isn't a way in the VS UI to change this. You should be able to modify the solution file though, and it should work.

- 27,142
- 5
- 87
- 100
-
2NOTE: This works but you MUST run Visual Studio as an administrator in order to open websites with a port less than 1000.... Also, note the location of the url in the Project("") tag example above. The one I had by default only had the name of the web project, not the launch url, so it was not obvious at first glance. – ExcaliburVT Jan 07 '15 at 21:15
-
I can't understand, I just run Visual Studio 2013 as an administrator and then open .sln solution file and VS propert show exactly same port configured at Visual Studio 2012 and then all is working fine. – Alexsandro Jul 15 '15 at 17:52
-
I have a Web Site Projetct on my network and when i change the settings, Visual Studio dont take use them. Does it create a local tmp sln ? – Fortin Oct 05 '15 at 20:14
Right click the web application and select "properties"
There should be a 'Web' tab where http://localhost:XXXXX
is specified - change the port number there and this will modify the configuration to use your new port number.
I usually start at 10000 and increment by 1 for each web app, to attempt to steer well clear of other applications and port numbers.

- 3,704
- 1
- 30
- 44
-
4Thank you but its disabled, I cannot change it. How can change it ? – Bengi Besçeli Apr 02 '14 at 20:30
-
Is it running? (the website) - close any instances of IIS Express and stop the debugging process first. – SpaceBison Apr 02 '14 at 20:30
-
2Ok, there are more detailed instructions here: http://msdn.microsoft.com/en-us/library/ms178109.ASPX - Tricky for me to tell without seeing what you're looking at! Try and follow the suggestions on that MSDN article if you're still having difficulties - there are four suggestions there - make sure you identify which one is correct out of the four. – SpaceBison Apr 02 '14 at 20:32
-
1It really hasn't changed too much - there's a 2013 version here which details how to get hold of and use IIS Express, which I'd recommend doing.... http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx – SpaceBison Apr 02 '14 at 20:56
Well, I simply could not find this (for me) mythical "Use dynamic ports" option. I have post screenshots.
On a more constructive note, I believe that the port numbers are to be found in the solution file AND CRUCIALLY cross referenced against the IIS Express config file
C:\Users\<username>\Documents\IISExpress\config\applicationhost.config
I tried editing the port number in just the solution file but strange things happened. I propose (no time yet) that it needs a consistent edit across both the solution file and the config file.

- 8,050
- 3
- 34
- 65
This has proved to be elusive for me (WebSite Project) until I figured out the following procedure, which combines the solution provided by @Jimmy, with the added step of checking out the solution from Source Control
Steps: (if using VS2013+ with website project and SourceControl)
- Check out the Solution file only (from sourceControl) (this can be tricky. the easiest way to do this is to make a small change in the Solution file properties/settings and then undo if necessary)
- Locate the solution file (e.g. solution.sln) in exploer, and open in text editor.
- Locate the entry:
VWDPort = ......
and change to desired port: (example: "60000" - depends on your IISExpress Settings) - save the change (will prompt to reload solution)

- 2,471
- 2
- 22
- 29
-
Nice, Thanks Danidev! Open a file .sln to search VWDPort is change a port, work a fine. Im used VS 2015 – KingRider May 19 '17 at 14:26
- Open Solution file (.sln) in Editable mode (Notepad or notepad++ or any other tool)
- Find tag name VMDPort and update it to your desired port.
see below snap.

- 5,869
- 4
- 38
- 58
-
1This is only for Web *Site* projects, not Web Applications. But it works. As others have done elsewhere I changed all the other mentions of the port number (TargetPath, VirtualPath) too. Also I had to quit Visual Studio, not merely close the solution, for this to work. This was done on VS 2019 16.9.2. – Josh Gallagher May 06 '21 at 11:25
To specify a port for the ASP.NET Development Server
In Solution Explorer, click the name of the application.
In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the dropdown list.
This will enable editing of the Port number property.
In the Properties pane, click the text box beside Port number and
type in a port number. Click outside of the Properties pane. This
saves the property settings.Each time you run a file-system Web site within Visual Web Developer, the ASP.NET Development Server will listen on the specified port.
Hope this helps.

- 2,356
- 17
- 19
-
7Thank you but my Visual Studio 2013 has not a property named 'Use dynamic ports'. – Bengi Besçeli Apr 02 '14 at 20:42
The Visual Studio Development Server option applies only when you are running (testing) the Web project in Visual Studio. Production Web applications always run under IIS.
To specify the Web server for a Web site project
- In Solution Explorer, right-click the name of the Web site project for which you want to specify a Web server, and then click Property Pages.
- In the Property Pages dialog box, click the Start Options tab.
- Under Server, click Use custom server.
- In the Base URL box, type the URL that Visual Studio should start when running the current project.
Note: If you specify the URL of a remote server (for example, an IIS Web application on another computer), be sure that the remote server is running at least the .NET Framework version 2.0.
To specify the Web server for a Web application project
- In Solution Explorer, right-click the name of the Web application project for which you want to specify a Web server, and then click Properties.
- In the Properties window, click the Web tab.
- Under Servers, click Use Visual Studio Development Server or Use Local IIS Web server or Use Custom Web server.
- If you clicked Local IIS Web server or Use Custom Web Server, in the Base URL box, type the URL that Visual Studio should start when running the current project.
Note: If you clicked Use Custom Web Server and specify the URL of a remote server (for example, an IIS Web application on another computer), be sure that the remote server is running at least the .NET Framework version 2.0.
(Source: https://msdn.microsoft.com/en-us/library/ms178108.aspx)

- 1,503
- 1
- 17
- 39
Steps to resolve this:
- Open the solution file.
- Find the Port tag against your project name.
- Assign any different port as current.
- Right click on your project and select Property Pages.
- Click on Start Options tab and checked Start URL: option.
- Assign the start URL in front of Start URL option like:
localhost:8080/login.aspx

- 6,138
- 12
- 49
- 61

- 263
- 2
- 4
- 11
This is the only solution that worked for me after trying several of those above. Switch to your c:\users folder and search for .sln and then remove all .sln files that have your project name. Then restart your computer and rebuild the solution (F5) and it worked!

- 1,226
- 3
- 23
- 41