Skip to content

CURL and localhost don't work

By Michael Wutzke,

CURL on Linux - command line tips for Elasticsearch

Every now and then even small tips can bring a big help. If you are a programmer who programs locally and uses Docker at the same time, you will most likely use CURL from time to time to process data. However, if you use “localhost” as the host name, you will quickly be disappointed. Because the query returns an ugly error message:

Failed to connect to localhost

The reason for this error message has to do with the dockerization of the containers. You can solve the problem by using the correct (internal) IP address of the running web server, but it’s much easier to just replace “localost” with “host.docker.internal”. Then CURL also works fine on a local development server.