Skip to content

WSL2 - Unable to access localhost:5000 #4500

@NEKN3X

Description

@NEKN3X

Please fill out the below information:

  • Your Windows build number: (Type ver at a Windows Command Prompt)

Microsoft Windows [Version 10.0.18956.1000]

  • What you're doing and what's happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screen shots if that helps demonstrate the problem.)

React front app
$ yarn start
Rails backend API
$ bundle exec rails s -b localhost -p 5000

  • What's wrong / what should be happening instead:

I want to connect my rails API but I can't.
If I type IP directly I can connect the API from react.
like
$ bundle exec rails s -b 172.xx.xx.xx -p 5000
cors.rb
origins /localhost:\d+/, /172.xx.xx.xx:\d+/

curl is OK
$ curl localhost:5000/users/1
{"status":"SUCCESS", ... }

but react
GET http://localhost:5000/users/1
net::ERR_CONNECTION_REFUSED

I am sorry I can't speak English well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions