Failed to connect to localhost

I have searched for a solution but could not find one. I want to connect to my server (pc) through localhost on port 8080 from another machine (laptop). I’ve tested few services (ollama, angular, spring), also tried access my pc from laptop. I disabled the firewall, and my netstat output is:

tcp6       0      0 :::8080                 :::*                    LISTEN     

curl output:

❯ curl http://localhost:8080
curl: (7) Failed to connect to localhost port 8080 after 0 ms: Couldn't connect to server

I don’t know, if it’s related but I can’t block some domanes in my /etc/hosts

I would be happy to receive some advice on what I can do.

Localhost is your local machine where you’re currently working on.

You need to use the actual hostname or IP address to connect.

First thing is your hosts file makes zero sense. Set it back to default.

I want to host it only on my local network.

Yes, but localhost is always just one machine: the one your currently using.

On another machine, localhost is that machine. You have to use the IP address of the machine to connect.

1 Like

Ok, but it doesn’t work even without those settings.

I the past I blocked it, for example according to this site:

I get it now. I thought that localhost refers to the local network.

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.