1

I'm working on a Docker related C# program.
Normally, when I launch it, it shows the Swagger UI, but this time, in the internet browser, I just see "localhost refused to connect", mentioning ERR_CONNECTION_REFUSED.

The so-called "details" are a joke:

Check your Internet connection
Check your network cables, modem, and routers.

Allow Microsoft Edge to access the network in your firewall or antivirus settings.
If it's already listed as a program allowed to access the network, try removing it from the list, and adding it again.

If you use a proxy server:
Check your proxy settings. You might need to ask your organization if the proxy server is working. If you don't think you should be using a proxy server, go to Settings > System > Open your computer's proxy settings

Just for being sure there's no problem with the "localhost" entry:

Commandline prompt>ping -a localhost

Pinging PORT-DDM.<servername> [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

There seems not to be a process, running on port 5128:

Commandline prompt>netstat -qon | findstr /I "5128"
=> no result

Commandline prompt>netstat -aon | findstr /I "5128"
=> no result

There are some other ports in the "neighbourhood" of 5128 in the general netstat -aon result:

...
TCP    [::]:3389   [::]:0   LISTENING   2012
TCP    [::]:5601   [::]:0   LISTENING   21660
TCP    [::]:5672   [::]:0   LISTENING   21660
...

Where 21660 is the PID of the so-called "Docker Desktop Backend".

As far as the rest of Docker is concerned: all containers are running, just like before.

Yesterday it was running fine, but today not. The only thing I've modified is a Windows update, currently I'm working with (winver result):

Windows 10
Version 21H2 (OS Build 19044.2486)

Oh, just in order to be sure: I have launched the following command:

Commandline prompt>docker-compose -f docker-compose.base.yml up

This did not solve the problem neither.

My /etc/hosts file (C:\Windows\System32\drivers\etc\hosts), viewed in Notepad++, looks as follows (modified today, according to the file's last modification date):

enter image description here

(Mind the bunch of Null characters at the beginning)

I have replaced this by:

# manually added localhost
127.0.0.1 localhost

# Added by Docker Desktop
10.1.xxx.xxx host.docker.internal
10.1.xxx.xxx gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

This did not solve the issue.

As far as the ASPNETCORE_ENVIRONMENT environment variable is concerned, this one is indeed set to "DEVELOPMENT", as you can see in the following container related information excerpt while debugging:

enter image description here

I just added two rules in my firewall, permitting the port 5128, inbound as well as outbound, it did not make a difference:

Inbound rule:

enter image description here

Outbound rule:

enter image description here

There are no proxy settings.

The result of docker ps for this particular container is the following (reworked for readability reasons):

Commandline prompt>docker ps

CONTAINER ID : e88e98a213ed
IMAGE        : image_svcapi:dev
COMMAND      : "tail -f /dev/null"
CREATED      : 5 days ago
STATUS       : Up 2 hours
PORTS        : 0.0.0.0:5128->80/tcp, 0.0.0.0:49154->443/tcp
NAMES        : Application_Svc.Api

Unfortunately, the command curl is not understood by my Docker container:

# curl http://localhost:80
/bin/sh: 3: curl: not found
# find / -name "curl"
find: '/proc/13748/task/13748/net': Invalid argument
find: '/proc/13748/net': Invalid argument
#

I tried apt install curl but I got the following error message:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package curl

(I get the same result for "libcurl" and "libcurl4-openssl-dev").

Outside, in a regular commandline, the curl command works and gives following result:

Commandline prompt>curl http://localhost:80
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>IIS Windows</title>
    <style type="text/css">
      <!--body { color:#000000;
                 background-color:#0072C6;
                 margin:0;}
      #container { margin-left:auto;
                   margin-right:auto;
                   text-align:center; }
      a img { border:none; }-->
    </style>
  </head>
  <body> <div id="container">
           <a href="http://go.microsoft.com/fwlink/?linkid=66318&amp;clcid=0x409">
             <img src="iisstart.png" alt="IIS" width="960" height="600"/>
           </a>
         </div>
  </body>
</html>

Does anybody have an idea?
Thanks in advance

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • CORS maybe....? – jazb Jan 19 '23 at 08:27
  • Note how localhost resolves to ipv6 address in your ping. Maybe your server listens on ipv4 loopback only? – Evk Jan 19 '23 at 08:29
  • @Evk: I've edited my question, adding information about the "/etc/hosts" of my machine. Apparently, this file has been altered by Docker, but I have no idea how it was before. Adding an IPv4 reference to `localhost` to this file did not solve the issue. – Dominique Jan 19 '23 at 08:54
  • Is this a Windows container or a Linux container that you run using WSL? – Hans Kilian Jan 19 '23 at 09:18
  • @HansKilian: my computer is Windows-10, the containers are all Linux, using WSL. The other containers are working fine, by which I mean that I can see them running in the Docker desktop and one of them (the MS-SQL server), works via Microsoft SQL Server management tools. My container works too, the logs show some "info" and "warning", but nothing more (the file `/var/log/messages` does not exist in the container, the command `dmesg` is not recognised). – Dominique Jan 19 '23 at 09:28
  • Do you see port mapping for this container in `docker ps` output? Also please check if the application is still running in container and is listening ports. And what happens if you open the link using IP address instead of localhost? – Mike Mozhaev Jan 19 '23 at 09:32
  • @MikeMozhaev: I've added the result of the `docker ps` command. – Dominique Jan 19 '23 at 09:42
  • @jazb: Pardon my ignorance (I'm a real newbie in Docker), but what does CORS mean? (I know it stands for Cross-Origin Resource Sharing), but how is this related to Docker and in case it's related, why didn't it bother my application before? – Dominique Jan 19 '23 at 09:46
  • Please logon to the shell with `docker exec Application_Svc.Api bash` or any other appropriate command and make sure that your application is listening inside the container on port 80. E.g. with `curl http://localhost:80`. – Mike Mozhaev Jan 19 '23 at 09:55
  • @MikeMozhaev: Sorry. I tried launching `curl` in the container terminal but the command is not known and `apt install` can't install it. I managed getting the command to work in a regular commandline but I'm afraid that's useless, isn't it? Again, I've edited my question, according to the question in your comment. Do you have any other idea? – Dominique Jan 19 '23 at 10:25
  • @MikeMozhaev: Oh, the command `docker exec Application_Svc.Api bash` does not work: I'm using the external terminal, proposed by Docker Desktop. – Dominique Jan 19 '23 at 10:36
  • @Dominique Any shell you can run is ok. Try to check if some application is listening on port 80. Here are some examples of how to do this: https://linuxize.com/post/check-listening-ports-linux/ – Mike Mozhaev Jan 19 '23 at 11:35
  • @MikeMozhaev: I'm sorry. I have just restarted my computer and to my own surprise now everything is working. The real problem is that I have no idea WHY it is working now and why not. I will now close this question, but I might use it in case the issue happens again. – Dominique Jan 19 '23 at 12:29

0 Answers0