0
votes

I am trying to access an app (Identity Server 4) that is hosted on my server at home. When I run app, I can curl localhost and get HTML of home page of Identity Server 4. But, when I try to access that app from my PC I constantly get "connection refused". I have open the port (in this case port is 5000) with ufw, but I still get "connection refused".

I don't know what should I be looking at, cause I am not very good with networking.

If I open

/etc/hosts

I get:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

And if I type ifconfig I get:

br-23aec2d805c1: flags=4163 mtu 1500 inet 172.19.0.1 netmask 255.255.0.0 broadcast 172.19.255.255 inet6 fe80::42:aff:fed1:afcf prefixlen 64 scopeid 0x20 ether 02:42:0a:d1:af:cf txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-a03307c6e330: flags=4099 mtu 1500 inet 172.21.0.1 netmask 255.255.0.0 broadcast 172.21.255.255 ether 02:42:dc:aa:49:c9 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

br-b2ac2102790e: flags=4099 mtu 1500 inet 172.20.0.1 netmask 255.255.0.0 broadcast 172.20.255.255 ether 02:42:9b:c4:58:a2 txqueuelen 0 (Ethernet) RX packets 68 bytes 5908 (5.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 68 bytes 5908 (5.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

docker0: flags=4163 mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 inet6 fe80::42:ccff:feb4:83d4 prefixlen 64 scopeid 0x20 ether 02:42:cc:b4:83:d4 txqueuelen 0 (Ethernet) RX packets 22655 bytes 5132534 (4.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26492 bytes 20375012 (19.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

docker_gwbridge: flags=4099 mtu 1500 inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255 ether 02:42:7d:64:08:fa txqueuelen 0 (Ethernet) RX packets 3763 bytes 690577 (674.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2977 bytes 1193212 (1.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno1: flags=4163 mtu 1500 inet 192.168.1.11 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::2111:8d94:12e1:3617 prefixlen 64 scopeid 0x20 ether 70:85:c2:7b:24:b5 txqueuelen 1000 (Ethernet) RX packets 669595 bytes 799790693 (762.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 476491 bytes 45305847 (43.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 16 memory 0xa1200000-a1220000

lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 68 bytes 5908 (5.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 68 bytes 5908 (5.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth0e6a280: flags=4163 mtu 1500 inet6 fe80::245e:eff:feeb:1bc2 prefixlen 64 scopeid 0x20 ether 26:5e:0e:eb:1b:c2 txqueuelen 0 (Ethernet) RX packets 156515 bytes 36954031 (35.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 135009 bytes 27523494 (26.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth0ed3eff: flags=4163 mtu 1500 inet6 fe80::88e6:81ff:fe80:1a6 prefixlen 64 scopeid 0x20 ether 8a:e6:81:80:01:a6 txqueuelen 0 (Ethernet) RX packets 1074962 bytes 171060799 (163.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 788326 bytes 341834817 (325.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth37e347a: flags=4163 mtu 1500 inet6 fe80::f0c3:60ff:fe57:c5dd prefixlen 64 scopeid 0x20 ether f2:c3:60:57:c5:dd txqueuelen 0 (Ethernet) RX packets 788306 bytes 341833385 (325.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1074982 bytes 171062231 (163.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth54e612a: flags=4163 mtu 1500 inet6 fe80::68a9:31ff:fe5b:f1f7 prefixlen 64 scopeid 0x20 ether 6a:a9:31:5b:f1:f7 txqueuelen 0 (Ethernet) RX packets 15416 bytes 4958650 (4.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 15485 bytes 862685 (842.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth7c3ac57: flags=4163 mtu 1500 inet6 fe80::d0d1:2dff:feed:f1bd prefixlen 64 scopeid 0x20 ether d2:d1:2d:ed:f1:bd txqueuelen 0 (Ethernet) RX packets 28 bytes 3522 (3.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 42 bytes 5131 (5.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

veth86f6af5: flags=4163 mtu 1500 inet6 fe80::e44d:3cff:fe01:6991 prefixlen 64 scopeid 0x20 ether e6:4d:3c:01:69:91 txqueuelen 0 (Ethernet) RX packets 3763 bytes 690577 (674.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2977 bytes 1193212 (1.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vethda6b63a: flags=4163 mtu 1500 inet6 fe80::d4db:9eff:fece:d3bc prefixlen 64 scopeid 0x20 ether d6:db:9e:ce:d3:bc txqueuelen 0 (Ethernet) RX packets 133961 bytes 27038265 (25.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 155294 bytes 37135106 (35.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

I am lost and I don't know what to do. What part should I modify and with what?

2

2 Answers

2
votes

How are you running the server? Is it using Kestrel, for example? Checking its current documentation indicates:

The Listen method binds to a TCP socket, and an options lambda permits X.509 certificate configuration

So it looks like you should be able to use something like:

WebHost.CreateDefaultBuilder(args)
 // ...
 .ConfigureKestrel((context, options) =>
 {
    options.Listen(IPAddress.Any, 5000);
 });
1
votes

The answer were pretty simple, but yet it never crossed my mind. Tanktalus was so close. When I used ConfigureKestrel, VS couldn't find that method, so instead of his sample, I used almost the same thing but with different method. This is the solution:

.UseKestrel(configure =>
{
     configure.Listen(System.Net.IPAddress.Any, 5055);
})