Feathers: Binding to "localhost" or to "0.0.0.0" at config/default.json and Docker

Created on 31 Dec 2019  路  9Comments  路  Source: feathersjs/feathers

I've recently updated my Docker version. The result of docker -v command now is

Docker version 19.03.5, build 633a0ea838

I'm mentioning this because my Feathers' APIs went broke only when dockerized. Although they were running fine when executed with npm start, I was getting a Connection rejected when running inside a Docker container.

My APIs are 'standard', created with feathers generate app command, running at Feathers' default port, 3030.

My Dockerfile, as always was

FROM node:lts-alpine
ENV NODE_ENV=development
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3030
CMD ["npm", "start"]

And suddenly, after updating Docker, all my APIs started presenting this Connection rejectederror. I tried many different possibilities:

  • Although docker ps command was reporting port 3030 as open, using nmap against the container would tell me all ports were closed.

  • I tried to use docker -P flag, which maps all open ports to higher ports. I continue getting the same error.

Then, finally, I've found this article here, which clearly states:

To fix this problem, bind your web server to 0.0.0.0 instead. This will allow anyone to connect to your web server as long as they have access to your network.

Then I changed

"host": "localhost"
to

"host": "0.0.0.0"

and everything worked again!

This is possibly related to Docker, but I considered it would be worth mentioning here, since this may cause trouble to FeathesJS users.

All 9 comments

Indeed, I started using Docker recently and this is what I had to do in order to make it works.

This has also been fixed (via https://github.com/feathersjs/generator-feathers/pull/520) when generating the application with the latest version of the CLI.

Sorry @daffl, but I thought I was using the latest version of the CLI. My answer to feathers --versioncommand is 4.2.4. Is this the last one?

Strange. Looks like it didn't get published properly. Definitely fixed now in @feathersjs/cli version 4.2.5.

Thanks!

Would it be expected to have "host:": "0.0.0.0" at config/default.json?

If so, we still have something wrong, sorry to say.

https://i.imgur.com/A79CWBd.png

This print was generated AFTER updating to 4.2.5

It probably doesn't matter. In the linked PR it now uses const server = app.listen(port); again which automatically listens on all hostnames.

Oh, ok! Thanks once more.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arkenstan picture arkenstan  路  3Comments

ausir0726 picture ausir0726  路  3Comments

perminder-klair picture perminder-klair  路  3Comments

Vincz picture Vincz  路  4Comments

intumwa picture intumwa  路  3Comments