With upgrade from Node 16 to 18, I noticed the IPv4 localhost (127.0.0.1) is no longer used.
By default is used IPv6 localhost (::1).
From curl with -vvv option:
* Trying 127.0.0.1:3000...
* connect to 127.0.0.1 port 3000 failed: Connection refused
* Trying [::1]:3000...
* Connected to localhost (::1) port 3000 (#0)
While it is not a problem for curl, it is a problem when one tries to call localhost with other clients, e.g. hosted on JVM.
Trying to reach localhost:3000 from Java (tested on Java 11 & 17), results with:
Execution error (ClosedChannelException) at sun.nio.ch.SocketChannelImpl/ensureOpen (SocketChannelImpl.java:195).
Current Behavior
IPv4 localhost is not available.
It is possible to use it but host: 127.0.0.1 needs to be specified in config, otherwise by default service is available under ::1.
Sample Code
file: serverless.yml
service: my-service
plugins:
- serverless-offline
provider:
runtime: nodejs18.x
stage: dev
functions:
hello:
events:
- http:
method: get
path: hello
handler: handler.hello
custom:
serverless-offline:
port: 3000
# host is not specified
Either make IPv4 localhost (127.0.0.1) reachable by default, or clear messaging in logs is needed that service is running exclusively on IPv6 localhost (::1).
@rynkowsg I can't reproduce the issue. Can you share a sample repo? The link to the sample app you gave doesn't seem to be a good example of the issue you are describing.
Bug Report
With upgrade from Node 16 to 18, I noticed the IPv4 localhost (127.0.0.1) is no longer used. By default is used IPv6 localhost (::1). From curl with
-vvv
option:While it is not a problem for curl, it is a problem when one tries to call localhost with other clients, e.g. hosted on JVM. Trying to reach localhost:3000 from Java (tested on Java 11 & 17), results with:
Current Behavior
IPv4 localhost is not available. It is possible to use it but
host: 127.0.0.1
needs to be specified in config, otherwise by default service is available under ::1.Sample Code
Expected behavior/code
Either make IPv4 localhost (127.0.0.1) reachable by default, or clear messaging in logs is needed that service is running exclusively on IPv6 localhost (::1).
Environment
serverless
version: 3.38.0serverless-offline
version: 13.5.0node.js
version: v18.20.2OS
: Fedora 38