Score:2

cURL can connect to localhost but browser cannot

th flag

My system is Win10 with WSL2, I ran a gogs docker container (from ubuntu in WSL):

    83b2a8833235   gogs/gogs                    "/app/gogs/docker/st…"   17 minutes ago   Up 17 minutes   0.0.0.0:10022->22/tcp, :::10022->22/tcp, 0.0.0.0:10080->3000/tcp, :::10080->3000/tcp       gogs

I found that I can cURL it, but cannot use browser to visit it:

    >curl -vvv http://localhost:10080
    * Rebuilt URL to: http://localhost:10080/
    *   Trying ::1...
    * TCP_NODELAY set
    * Connected to localhost (::1) port 10080 (#0)
    > GET / HTTP/1.1
    > Host: localhost:10080
    > User-Agent: curl/7.55.1
    > Accept: */*
    >
    < HTTP/1.1 302 Found
    < Content-Type: text/html; charset=utf-8
    < Location: /install
    < Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
    < Set-Cookie: i_like_gogs=64602dcbf733a9e0; Path=/; HttpOnly
    < Set-Cookie: _csrf=CEoPJD9KItxBKOThbeQExNAjnDo6MTYyNzQ4MDI3Njg1MDY2NTEwMA; Path=/; Domain=localhost; Expires=Thu, 29 Jul 2021 13:51:16 GMT; HttpOnly
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: DENY
    < Date: Wed, 28 Jul 2021 13:51:16 GMT
    < Content-Length: 31
    <
    <a href="/install">Found</a>.
    
    * Connection #0 to host localhost left intact

Using netstat -a -o I can see the address in Active Connections:

TCP    0.0.0.0:10080          xxxxxxx:0          LISTENING       13152

But I cannot visit using browser: Cannot Visit Using Browser

Anyone has any hints?

jp flag
Dom
Do you have a proxy in your browser ? Or anti-virus which blocks ? The proxy may block of you use the "unsafe port" 10080...
Ken Tsoi avatar
th flag
@vidarlo it is WSL2, sorry for the confusion
Ken Tsoi avatar
th flag
@Dom did not see any strange things on the proxy (only the "Automatically detect settings" is set to ON)
dave_thompson_085 avatar
jp flag
The error text is misleading: Chrome isn't having trouble connecting, **Chrome isn't _trying_ to connect** -- see https://superuser.com/questions/188058/which-ports-are-considered-unsafe-by-chrome . Firefox gives a much better error: "This address is restricted / This address uses a network port which is normally used for purposes other than Web browsing. Firefox has canceled the request for your protection." Your best solution is to choose a different port.
Ken Tsoi avatar
th flag
Thanks @dave_thompson_085 for the knowledge, it works when I change the port.
Score:6
za flag

Most Browsers restrict 10080 for security reasons on localhost

Solution

  • Change the Port.

References

Google Chrome blocks port 10080 to stop Nat slip streaming attacks
Chrome Platform

Additonal Informations:

Currently, Google Chrome is blocking also FTP, HTTP, and HTTPS access on ports 69, 137, 161, 554, 1719, 1720, 1723, 5060, 5061, and 6566.

djdomi avatar
za flag
As Also, the most modern browsers do the same.
Ken Tsoi avatar
th flag
Thanks @djdomi for the knowledge!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.