Search code examples
linuxubuntunetwork-programminghugonetworkmanager

Ubuntu local IP address does not resolve


I set a Hugo web server, which listen on localhost:30000. The ubuntu machine has the 192.168.2.137 address.

When i do:

curl http://localhost:30000/ -> OK
curl http://127.0.0.1:30000/ -> OK

but,

curl http://192.168.2.137:30000/ -> curl: (7) Failed to connect to 192.168.2.131 port 30000: Connection refused

What could be the reason for that?

My /etc/netplan/00-installer-config.yaml looks like:

network:
version: 2
renderer: NetworkManager
ethernets:
  enp0s3:
    dhcp4: false
    addresses: [192.168.2.137/24]
    gateway4: 192.168.2.1
    nameservers:
      addresses:
        - 8.8.8.8
  lo:
    renderer: networkd
    match:
      name: lo
    addresses:
      - 192.168.2.137/24

I also add an entry to /etc/hosts:

192.168.2.137 localhost

Solution

  • You said that it’s listen on localhost so if you use other interface it won’t work which is normal . You should listen on all interfaces or listen to the interface enp0s3.