0

I have a problem when I try to access a json server on docker, no errors, no response. I tried to access using telnet and return was "Connection closed by foreign host"

My docker-compose is like

version: "3"
services:
  json-server:
    build: ./
    volumes:
      - ./:/app
    ports:
      - "3080:3080"
    command: ["yarn", "start:server"]

my command yarn start:server is running like:

json-server --watch --port 3080 ./db/data.json

The container still running, no errors, no response is like not accessible. The response from telnet localhost 3080 is:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

Do you have any idea ?

Thanks

  • You almost certainly need a `--host 0.0.0.0` option; see also [Running json-server in docker](https://stackoverflow.com/questions/50784868/running-json-server-in-docker) (this detail is in the question, not an answer). – David Maze Feb 15 '21 at 19:28
  • 1
    exactly this, I tried to force my local ip and doesn't work, but setting 0.0.0.0 works! Thank you – chris_wt Feb 15 '21 at 19:44

0 Answers0