I work on aspnet core web api project. I will publish this project to remote server. When Kestrel is running, default port is 5000 or anythink like this.
I want to change this port to 80 or 8080. Can I do that?
When I try to change from launchSettings, I get this error:
System.IO.IOException: 'Failed to bind to address http://localhost:80.'
Your problem may be because you already have another web server running on your system (e.g. IIS) that is already binding to port 80.
You can check with this powershell command:
Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess
This command will show you what process is listening on port 80. If nothing is listening, it will return an error.
Related
When specifying a port to bind to with .UseKestrel() I get the errors listed below.. but if I remove the kestrel options everything works normally if I check the API from my browser.
I've tried binding to the port that my application defaults to with no ports chosen and I've tried checking netstat to actively avoid any ports that are in use. Nothing works but removing the options entirely. This is not replicated on my Mac or another Windows 10 machine. This device is Windows 10.
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, 50470);
options.Listen(IPAddress.Any, 80);
})
: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'http://localhost:50470/'. Binding to endpoints defined
in UseKestrel() instead.
crit: Microsoft.AspNetCore.Server.Kestrel[0]
Unable to start Kestrel.
System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions
at
System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException
(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress
socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.
BindAsync() at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.
<>c__DisplayClass21_01.<<StartAsync>g__OnBind|0>d.MoveNext() `
Also check Darkthread's answer here: https://superuser.com/questions/1486417/unable-to-start-kestrel-getting-an-attempt-was-made-to-access-a-socket-in-a-way
We discovered that a port we had been using for a long time wasn't acccessible anymore because it had been reserved by Windows! You may wish to check reserved ports using this command:
netsh interface ipv4 show excludedportrange protocol=tcp
After Windows Update, some ports are reserved by Windows and applications cannot bind to these ports. please check this command for forbiden port on Os
netsh interface ipv4 show excludedportrange protocol=tcp
In my case, Removing invalid local IP and Port address combinations from the app's launchSettings.json did it.
The additional binding of port 80 in ".UseKestrel(options => { options.Listen(...) })" was causing the issue in my case.
When you run an ASP.NET Core application directly through Kestrel, without an additional reverse proxy like IIS or nginx, you will need to configure the hosting URL properly.
The problem was because, you did not follow Port sharing limitation in Kestrel web server.
When you to use the Kestrel web server, you should set unique port to app. (if you use the port 80, make sure no apps use this port).
and your app has enough permissions, too.
more info:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.2
I hope is useful.
Try Updating The Https Certificate
with this command. It worked for me!!
dotnet dev-certs https
The problem was with the additional binding of port 80, updating this corrected the problem.
I have a self-hosted SignalR application in a Windows Service built with VS2015 FW 4.6, SignalR 2.3.0. This has been working fine for more than 2 years using ports 6286 (https) and 6287 (http) and "*" for the IP. I wanted to switch these ports to 80 and 443 respectively and apply a wild-card certificate to 443. Since there are web sites using the certificate on IP 192.168.100.7 I added another IP address (192.168.100.3) to my server applied the certificate with:
netsh http add sslcert ipport=192.168.100.3:443 appid={12345678-db90-4b66-8b01-88f7af2e36bf} certhash=xxxxxxxxxxxxxxxxxxxxxxxxx
I can verify the success with:
netsh http show sslcert ipport=192.168.100.3:443
So I start the WebApps with the following:
SignalR = WebApp.Start("http://192.168.100.3:80/");
SignalRSSL = WebApp.Start("https://192.168.100.3:443/");
They seem to start fine, no errors and if I use http://192.168.100.3/signalr/hubs it works fine. However, https://192.168.100.3:443/signalr/hubs gives the "Unexpectedly closed connection" error.
What have I done wrong, is there something else to set for https?
My error... I was using the internal IP's and corresponding external IP's to test this. What I realized is that the wild-card certificate is not tied to an IP, it's tied to a domain! So, I created an A record for the IP with the wild-card's domain and it worked.
However, I now have a different problem in that it's trying to negotiate with the web server's domain and not the signalR domain to send a message!
https://webserverdomain/signalr/negotiate?clientProtocol=1.5....
I don't know where it's picking the web server's name up but it's different enough that it's probably a topic for another post.
I'm try to use t32apinet.dll on host V (Win7 embedded 32bit) to connect with host W (Win 7 64bit).
TRACE32 on host W is already configured in config.t32 to accept a connection:
; Remote Control Access
RCL=NETASSIST
PORT=20000
PACKLEN=1024
TRACE32 is running on W while I try to config the driver and to establish the connection from V as follows:
T32 = new T32API();
T32.Config("NODE=", "192.168.100.2");//all Config returns 0 (no errors)
T32.Config("PACKLEN=", "1024");
T32.Config("PORT=", "20000");
T32.Init();//returns -1
//T32.Attach((int) T32API.Device.ICD);
On W I see incoming packages on port 20000 when Init() is executed on V.
Any ideas why Init() return with error?
Additional info regarding comments bellow:
I'm using T32Start-Tool to start Trace32, where using of API Port is activated and port value: 20000 is set
calling t32remtest.exe 192.168.100.2 port=20000 on remote PC returns:
error initializing TRACE32
error initializing TRACE32
The minimum viable settings block for enabling the Remote API port of TRACE32 in your configuration file is:
RCL=NETASSIST
PORT=20000
Please make sure to include an empty line before and after the block and that the correct TRACE32 configuration file is selected during start-up.
If you are using the T32Start utility to start TRACE32, the configuration file gets dynamically generated and is not necessarily identical with the default one config.t32.
although I saw the incoming packages in the sniffer there was no reactions from TRACE32.
The problem was that Windows recognized that network as public and blocked packages on the application level. Due to specific local IT policies the solution for me is to create a rule in windows firewall to explicitly allow communication on UDP port 20000:
screen with settings for new inbound rule in Win firewall
I want to ask for your help on how can connect to my Cassandra DB on my droplet from remote machine. I did everything that is written in this article: Install Cassandra but when I try to connect from my C# code:
cluster = Cassandra.Cluster.Builder()
.WithCredentials("abc", "abc")
.AddContactPoints(new[] { "12.34.56.78" })
.WithPort(9168)
.Build();
var session = cluster.Connect();
var keyspace = "Test";
session.CreateKeyspaceIfNotExists(keyspace);
session.ChangeKeyspace(keyspace);
I'm getting an Exception:
'Cassandra.NoHostAvailableException' in Cassandra.dll
Additional information: None of the hosts tried for query are available
(tried: 12.34.56.78:9168)
I also tried from other Cassandra GUI Clients like DBeaver but I'm getting the same error.
My Droplet is Ubuntu 14.04. From localhost I have no problem with Cassandra my only problem is from remote.
Here is result from
sudo netstat -plunt
Why could this be and how do I fix this?
You have to use port 9042.
listen_interface is used to setup inter-node communication.
The IP address or hostname that Cassandra binds to for connecting to other Cassandra nodes. Set this parameter or listen_interface, not both.
You have to change rpc_address and then restart cassandra daemon
(Default: localhost) The listen address for client connections (Thrift RPC service and native transport). Valid values are:
make sure you can run cqlsh locally, i.e. from the host where Cassandra is running. If you can not, check if Cassandra is running (check logs) and listens on the interface you are connecting to.
if you can connect locally, check you settings for rpc_address and rpc_broadcast_address for Cassandra. It should be set to other value than 'localhost' (which is set by default).
9042 port is for CQL by default, I suggest you not to reset it.
I am trying to start up a web app with visual studio, and I keep getting the error:
The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020).
I did some digging and i found that port 80 was used by the actual System proccess(lol) so i changed the default web site port from IIs manager to something that is not used by anything. I am still getting the error though.
One thing to note is that I can fire up a new website project but not a web application.
Windows 10.
Thanks
some application (check Skype connection port setting) can block ports
or use console:
netstat -aon | find «:80»
netstat -aon | find «:443»