Docker will not start after you add a TCP listener or hosts
docker.socket: Failed with result 'service-start-limit-hit'Short answer
service-start-limit-hit only says systemd gave up after repeated failed starts. The real error is in why dockerd exits. After you enable a TCP listener, it is nearly always the same option set twice: hosts in daemon.json and -H on the systemd command line. Set it in one place only, reload systemd and restart.
Fix it fast
1Find out which cause you have
Run the daemon in the foreground with the same config. It prints its own error and does not hide it behind systemd's retry limit. Stop with Ctrl+C.
sudo dockerd2Match what you see, then jump to its fix
- 1
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hostshosts is set in daemon.json and in the systemd unitFix - 2
same message, after following a guide that edits docker.service with systemctl editYou use a systemd override with -H and also kept hosts in daemon.jsonFix - 3
the following directives are specified both as a flag and in the configuration file: <option name>Another option is set both as a flag and in daemon.jsonFix
- 1
What does the error look like?
docker.socket: Failed with result 'service-start-limit-hit'docker.service: Failed with result 'exit-code'the following directives are specified both as a flag and in the configuration file: hosts
Cause 1 of 3
hosts is set in daemon.json and in the systemd unit
1Check
On Debian and Ubuntu the packaged unit starts dockerd with -H fd://. If /etc/docker/daemon.json also has a hosts entry, the daemon refuses to start.
cat /etc/docker/daemon.json
systemctl cat docker.service | grep ExecStart2Fix
Create a drop-in that empties the unit's ExecStart and starts dockerd without -H. The hosts list in daemon.json then decides where it listens. Keep a unix socket in that list if you still want the local CLI to work.
# /etc/systemd/system/docker.service.d/docker.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
# /etc/docker/daemon.json
{ "hosts": ["unix:///var/run/docker.sock", "tcp://127.0.0.1:2375"] }3Verify
Reload systemd and restart Docker, then check the daemon is active.
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl is-active dockerConfirmed by docs.docker.com
Cause 2 of 3
You use a systemd override with -H and also kept hosts in daemon.json
1Check
The remote-access guide sets the listener in a systemd override. If you do that, daemon.json must not also contain hosts. Having both is the conflict, from the other side.
systemctl cat docker.service
grep hosts /etc/docker/daemon.json2Fix
Pick one method. To keep the override, delete hosts from daemon.json, then reload and restart.
sudo systemctl edit docker.service
# [Service]
# ExecStart=
# ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:23753Verify
Restart and confirm dockerd listens on the port.
sudo systemctl daemon-reload
sudo systemctl restart docker.service
sudo netstat -lntp | grep dockerdConfirmed by docs.docker.com
Cause 3 of 3
Another option is set both as a flag and in daemon.json
1Check
Any option can trigger the same refusal, not only hosts. The message names the option. Look for it in the unit's ExecStart line and in daemon.json.
systemctl cat docker.service | grep ExecStart
cat /etc/docker/daemon.json2Fix
Keep the option in one place and delete it from the other.
sudoedit /etc/docker/daemon.json3Verify
Restart the service and check it is active.
sudo systemctl restart docker
sudo systemctl is-active dockerConfirmed by docs.docker.com
How do I stop it coming back?
- Choose one way to configure the daemon, daemon.json or systemd flags, and keep to it.
- After any change run dockerd in the foreground once to see its error before blaming systemd.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
The docker command cannot reach the Docker daemon
Cannot connect to the Docker daemon at unix:///Users/<user>/.docker/run/docker.sock. Is the docker daemon running?
This error means the docker client could not talk to a running daemon.
4 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fix