Can connect to localhost linux

Docker on Ubuntu unable to connect to localhost but works connecting to its ip

So I can see that it’s running on the port 80/tcp. Not sure why it does not run on port 8080 which is where I wanted to map it. Also, the http://[::]:80 seems confusing. I’ve read something about it being IPv6. No idea what consequences this has or why normal IPv4 wouldn’t work. My interface info:

$ ifconfig docker0: flags=4163 mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 inet6 fe80::42:71ff:fe7f:305 prefixlen 64 scopeid 0x20 ether 02:42:71:7f:03:05 txqueuelen 0 (Ethernet) RX packets 131843 bytes 105630866 (105.6 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 201439 bytes 268197990 (268.1 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp3s0: flags=4099 mtu 1500 ether 1c:1b:0d:a4:83:16 txqueuelen 1000 (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 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 118628 bytes 17999594 (17.9 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 118628 bytes 17999594 (17.9 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vethca5fd09: flags=4163 mtu 1500 inet6 fe80::3c56:d6ff:fe0c:846 prefixlen 64 scopeid 0x20 ether 3e:56:d6:0c:08:46 txqueuelen 0 (Ethernet) RX packets 7 bytes 533 (533.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 52 bytes 7342 (7.3 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlp6s0: flags=4163 mtu 1500 inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::8a58:c682:3833:3bb1 prefixlen 64 scopeid 0x20 ether e4:be:ed:4f:0f:21 txqueuelen 1000 (Ethernet) RX packets 519710 bytes 524989683 (524.9 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 439859 bytes 165781721 (165.7 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

So.. docker interface seems to have the address 172.17.0.1 . However I cannot access my container using the following urls:

$ curl http://localhost:8080 curl: (7) Failed to connect to localhost port 8080: Connection refused $ curl http://localhost:80 curl: (7) Failed to connect to localhost port 80: Connection refused $ curl http://0.0.0.0:80 curl: (7) Failed to connect to 0.0.0.0 port 80: Connection refused $ curl http://0.0.0.0:8080 curl: (7) Failed to connect to 0.0.0.0 port 8080: Connection refused $ curl http://172.17.0.1:8080 curl: (7) Failed to connect to 172.17.0.1 port 8080: Connection refused $ curl http://172.17.0.1:80 curl: (7) Failed to connect to 172.17.0.1 port 80: Connection refused $ curl http://127.0.0.1:8080 curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused $ curl http://127.0.0.1:80 curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused 

so no access using localhost , 127.0.0.1 or the docker interface IP. If I inspect the container:

sasw@Z3:~$ docker inspect 6f5bea7b329d [ < "Id": "6f5bea7b329d05bcb534953745f376da9c7efbe54de5532f8648b618152b722a", "Created": "2020-04-20T13:06:37.883347676Z", "Path": "dotnet", "Args": [ "SampleWebApp.dll", "-p", "8080:80" ], "State": < "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 30636, "ExitCode": 0, "Error": "", "StartedAt": "2020-04-20T13:06:38.295411125Z", "FinishedAt": "0001-01-01T00:00:00Z" >, "Image": "sha256:e00403d6c5eb3ccbe3c5c7b6ec8cf8289158e4c9fbe6ff5872ea932e69d60f38", "ResolvConfPath": "/var/lib/docker/containers/6f5bea7b329d05bcb534953745f376da9c7efbe54de5532f8648b618152b722a/resolv.conf", "HostnamePath": "/var/lib/docker/containers/6f5bea7b329d05bcb534953745f376da9c7efbe54de5532f8648b618152b722a/hostname", "HostsPath": "/var/lib/docker/containers/6f5bea7b329d05bcb534953745f376da9c7efbe54de5532f8648b618152b722a/hosts", "LogPath": "/var/lib/docker/containers/6f5bea7b329d05bcb534953745f376da9c7efbe54de5532f8648b618152b722a/6f5bea7b329d05bcb534953745f376da9c7efbe54de5532f8648b618152b722a-json.log", "Name": "/dreamy_leavitt", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "docker-default", "ExecIDs": null, "HostConfig": < "Binds": null, "ContainerIDFile": "", "LogConfig": < "Type": "json-file", "Config": <>>, "NetworkMode": "default", "PortBindings": <>, "RestartPolicy": < "Name": "no", "MaximumRetryCount": 0 >, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Capabilities": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DeviceRequests": null, "KernelMemory": 0, "KernelMemoryTCP": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": null, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "MaskedPaths": [ "/proc/asound", "/proc/acpi", "/proc/kcore", "/proc/keys", "/proc/latency_stats", "/proc/timer_list", "/proc/timer_stats", "/proc/sched_debug", "/proc/scsi", "/sys/firmware" ], "ReadonlyPaths": [ "/proc/bus", "/proc/fs", "/proc/irq", "/proc/sys", "/proc/sysrq-trigger" ] >, "GraphDriver": < "Data": < "LowerDir": "/var/lib/docker/overlay2/8f56c544522ccb6556358601706cb900c405c19b47e54c25d8b3dac979100e5b-init/diff:/var/lib/docker/overlay2/81bfee49e33d9761a6ca78dfd6f3f9a54a9333b4d4fc9986e8084f6b45232f04/diff:/var/lib/docker/overlay2/c2add2cb2d687126c6826c7dd9e1c85be1473a53d6b878554aa87615701344a0/diff:/var/lib/docker/overlay2/ebd0b92c5111423fb8d1219f757e41013a1473bdbe5cf3553cecbd4337f76766/diff:/var/lib/docker/overlay2/9197af6ebe4c70f0a84c7c267b1ba069aa710d917abe9fb3fee13320a17ab765/diff:/var/lib/docker/overlay2/1f463e8667b6eecc7c251ac05316b8d5d32840bff13d9f5cb7853c88e6f1f40e/diff:/var/lib/docker/overlay2/b7c9450f53334bef02f50cc854b33140b97f4ff3d2343b3fcac7b20f647c454e/diff", "MergedDir": "/var/lib/docker/overlay2/8f56c544522ccb6556358601706cb900c405c19b47e54c25d8b3dac979100e5b/merged", "UpperDir": "/var/lib/docker/overlay2/8f56c544522ccb6556358601706cb900c405c19b47e54c25d8b3dac979100e5b/diff", "WorkDir": "/var/lib/docker/overlay2/8f56c544522ccb6556358601706cb900c405c19b47e54c25d8b3dac979100e5b/work" >, "Name": "overlay2" >, "Mounts": [], "Config": < "Hostname": "6f5bea7b329d", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "ExposedPorts": < "80/tcp": <>>, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "ASPNETCORE_URLS=http://+:80", "DOTNET_RUNNING_IN_CONTAINER=true" ], "Cmd": [ "-p", "8080:80" ], "Image": "registry.gitlab.com/ddd-malaga/continuous-deployment-gitlab-docker-dotnet:latest", "Volumes": null, "WorkingDir": "", "Entrypoint": [ "dotnet", "SampleWebApp.dll" ], "OnBuild": null, "Labels": <> >, "NetworkSettings": < "Bridge": "", "SandboxID": "4e53bd2bc6cb83b7c0cba9fcdf07eb564a11ca6b955514670ba3f464aa0a96b7", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": < "80/tcp": null >, "SandboxKey": "/var/run/docker/netns/4e53bd2bc6cb", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "83976112bb202b79880777563cd1b06ef27781fd288b210b19fb499e3bf51c90", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "MacAddress": "02:42:ac:11:00:02", "Networks": < "bridge": < "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "7589efd57cea8d2b04823657fcfc54225991bc58c93ff0e463b6f12acb28b853", "EndpointID": "83976112bb202b79880777563cd1b06ef27781fd288b210b19fb499e3bf51c90", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02", "DriverOpts": null >> > > ] 

I can see the IP Address 172.17.0.2 . Again, I don’t know where this comes from. But now I can try to access the container IP at the port I told it to map:

$ curl http://172.17.0.2:8080 curl: (7) Failed to connect to 172.17.0.2 port 8080: Connection refused 
sasw@Z3:/$ curl http://172.17.0.2:80 Hello World! 
$ docker run myimage:latest -p 1234:1234 Status: Downloaded newer image for registry.gitlab.com/myimage:latest info: Microsoft.Hosting.Lifetime[0] Now listening on: http://[::]:80 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: / 

it seems those ports are completely ignored and it remains listening on the container ip and port 80

$ curl http://172.17.0.2:80 Hello World! 

Источник

Читайте также:  Топ лучших линукс дистрибутивов

Не могу подключиться к localhost [дубликат]

Не могу подключиться к 127.0.0.1, на любой порт фаерфокс пишет «connection blocked». Не знаю, в чем вообще причина, вот что говорят некоторые команды. ifconfig:

enp0s25: flags=4099 mtu 1500 ether 68:b5:99:f0:5a:87 txqueuelen 1000 (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 device interrupt 20 memory 0xd0700000-d0720000 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 384 bytes 31396 (30.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 384 bytes 31396 (30.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlo1: flags=4163 mtu 1500 inet 192.168.0.83 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::7705:a362:6896:aa73 prefixlen 64 scopeid 0x20 inet6 fd01::8b8e:b898:43cf:5abd prefixlen 64 scopeid 0x0 ether 00:23:14:17:f3:3c txqueuelen 1000 (Ethernet) RX packets 30236 bytes 21577035 (20.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 27621 bytes 5027406 (4.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 
$ telnet -4 localhost Trying 127.0.0.1. telnet: connect to address 127.0.0.1: Connection refused Trying 127.0.0.1. telnet: connect to address 127.0.0.1: Connection refused $ telnet -6 localhost Trying ::1. telnet: connect to address ::1: Connection refused 
$ netstat -anp|grep 127.0.0.1 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - udp 0 0 127.0.0.1:323 0.0.0.0:* - 

curl 127.0.0.1:8000 , что интересно, грузит HTML-код с сервера, правда, без CSS и JavaScript. В браузере во вкадке сначала пишет заголовок сайта, а затем connection blocked! . Делаю проект на Django. Подскажите, что можно сделать? Что еще привести, сходу не знаю, поэтому вот. Fedora 29, если что.

Читайте также:  Linux load cpu 100

Источник

Cannot connect to any localhost connections

I’am using Centos 6.5 with latest updates. My problem is that whenever i try to connect to some local service it just hangs for example:

wget

wget 127.0.0.1 --2014-03-11 12:43:42-- http://127.0.0.1/ Connecting to 127.0.0.1:80. After a while timeout. 
# ssh 127.0.0.1 -p 6060 -v OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to 127.0.0.1 [127.0.0.1] port 6060. debug1: connect to address 127.0.0.1 port 6060: Connection timed out ssh: connect to host 127.0.0.1 port 6060: Connection timed out 

and it hangs out to timeout. Same with telnet, and same with connecting to irc server. External connections are running fine.

netstat -tpln

# netstat -tpln Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 589/sendmail tcp 0 0 127.0.0.1:6060 0.0.0.0:* LISTEN 520/sshd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 619/nginx tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 478/sshd tcp 0 0 ::1:6060 . * LISTEN 520/sshd tcp 0 0 . 22 . * LISTEN 478/sshd 

netstat -rn

# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 venet0 0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 venet0 

iptables

# iptables -nvL Chain INPUT (policy ACCEPT 634 packets, 49819 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 517 packets, 47027 bytes) pkts bytes target prot opt in out source destination 

Loopback config

# ip a 1: lo: mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: venet0: mtu 1500 qdisc noqueue state UNKNOWN link/void inet 127.0.0.1/32 scope host venet0 inet 176.122.224.115/32 brd 176.122.224.115 scope global venet0:0 

ip route show table local

# ip route show table local local 176.122.224.115 dev venet0 proto kernel scope host src 176.122.224.115 broadcast 176.122.224.115 dev venet0 proto kernel scope link src 176.122.224.115 broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1 broadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1 local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1 local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1 

traceroute

# traceroute 127.0.0.1 traceroute to 127.0.0.1 (127.0.0.1), 30 hops max, 60 byte packets 1 localhost.localdomain (127.0.0.1) 0.029 ms 0.014 ms 0.012 ms 

ping 127.0.0.1

# ping 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.024 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.036 ms 

The weirdest thing about it is that, i can connect to ssh, nginx server from external address (for ex. computer from which i ssh’ing) without problems. This happens after ISP has rebooted my server. Thing that maybe useful is that, server was frequently updated without reboots.

Читайте также:  Install exe files on linux

Источник

Оцените статью
Adblock
detector