Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv4 localhost (127.0.0.1) is no longer default host with Node 18 #1783

Open
rynkowsg opened this issue May 1, 2024 · 1 comment
Open

IPv4 localhost (127.0.0.1) is no longer default host with Node 18 #1783

rynkowsg opened this issue May 1, 2024 · 1 comment

Comments

@rynkowsg
Copy link

rynkowsg commented May 1, 2024

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:

*   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

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.0
  • serverless-offline version: 13.5.0
  • node.js version: v18.20.2
  • OS: Fedora 38
@DorianMazur DorianMazur added the bug label May 3, 2024
@DorianMazur DorianMazur removed the bug label May 19, 2024
@DorianMazur
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants