I'm trying to connect to a service running on a google cloud platform VM from the ssh terminal.
The running process is listening on 7076 as shown here:
ced@instance-1:~$ sudo ss -ltn
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 1024 [::1]:7076 [::]:*
I also have the following firewall rule that allows internal connection:
Name Type Targets Filters Protocols/ports
default-allow-internal Ingress Apply to all IP ranges: 10.128.0.0/9 tcp:0-65535, udp:0-65535
When using the command:
curl -X POST --data '{"action": "benchmark"}' localhost:7076
The response is:
curl: (7) Failed to connect to localhost port 7076: Connection refused
As I understand:
- [::1]:7076 means my service is listening to connection on local host only
- I connected through ssh and then used curl, which is an internal connection (ie: from localhost)
Therefor I don't see why I cannot connect.
CodePudding user response:
As John Hanley is mention, your application is listening on IPv6, you can identified with the local address and port referred as "[::1]:7076".
The loopback address 0000:0000:0000:0000:0000:0000:0000:0001 is abbreviated to ::1.
To used the IPv6 with a curl is necesary to run as the following esplained on the manual page.
- -6: This option is to used only IPv6 protocol.
- -g: This option switches off the "URL globbing parser". When you set this option, you can specify URLs that contain the letters {}[] without having them being interpreted by curl itself.