I'm trying to run mosquitto as docker container in windows 10. Getting below error log Address not available.
1614449526: mosquitto version 2.0.7 starting
1614449526: Config loaded from /mosquitto/config/mosquitto.conf.
1614449526: Starting in local only mode. Connections will only be possible from clients running on this machine.
1614449526: Create a configuration file which defines a listener to allow remote access.
1614449526: Opening ipv4 listen socket on port 1883.
1614449526: Opening ipv6 listen socket on port 1883.
**1614449526: Error: Address not available**
1614449526: mosquitto version 2.0.7 running
Could anyone advise how to solve this error?
Thank you.
I'd the same issue.
My solution was:
Enter to mosquitto container item from portainer.io. then you must loggin by console in mosquitto's container. Select command : /bin/sh for loggin...
Once into command line must to adjust the mosquitto.conf located in : /mosquitto/config
Must change the following parameters: Uncomment and fixed
listener 1883
persistence true
allow_anonymous true
later, exit from command console and restart mosquitto container...and ready !!
check logs!
Hope to help!
i followed Stéphane Trottier's suggestion but ran into issues b/c of the port and an outdated config change:
allow_anonymous true
listener 2883
protocol mqtt
i also used port 2883 instead since it seems 8883 is for tls so i was getting connection refused errors on the client and protocol errors on the server. my docker compose looks like this:
mqtt:
image: eclipse-mosquitto:latest
volumes:
- ./mqtt/config:/mosquitto/config
user: "1000:1000"
ports:
- 1883:2883
I had the same issue yesterday... Generally, some OSs require more permissions to run services on ports lower than 2000. This is how I made it work for me. I'm just running this for a hobby project. For work I would do things differently.
added local mosquitto folder and placed mosquitto.conf file in it.
added allow_anonymous true
changed port to something higher than 2000.
mount local config volume in docker
allow_anonymous true
port 8883
I run it via docker compose file.
version: '3.1'
services:
mosquitto:
image: eclipse-mosquitto
hostname: mosquitto
container_name: mosquitto
ports:
- "8883:8883"
volumes:
- ./mosquitto:/mosquitto/config
networks:
- webnet
networks:
webnet:
The error is gone from my logs and I can connect to it just fine on that port.
1614505908: The 'port' option is now deprecated and will be removed in a future version. Please use 'listener' instead.
1614505908: mosquitto version 2.0.7 starting
1614505908: Config loaded from /mosquitto/config/mosquitto.conf.
1614505908: Opening ipv4 listen socket on port 8883.
1614505908: Opening ipv6 listen socket on port 8883.
1614505908: mosquitto version 2.0.7 running
looks like I'll have to replace port with listener at some point soon.
both azegurelabs and Stéphane Trottier answers worked for me.
but the easier and more accurate solution is to just run image with default provided conf
docker run -it --rm --name mosquitto -p 1883:1883 eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf
or to run image with your config file
docker run -it -p 1883:1883 -v <absolute-path-to-configuration-file>:/mosquitto/config/mosquitto.conf eclipse-mosquitto:<version>
you can read more here: mosquitto docker github page
Related
I want to use port 8080 on my local machine for a container service. Here is the relevant part of my docker-compose
services:
pgadmin:
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=admin#admin.com
- PGADMIN_DEFAULT_PASSWORD=root
volumes:
- "./data_pgadmin:/var/lib/pgadmin:rw"
ports:
- "8080:80"
However, port 8080 was already in use by other process when I ran docker-compose up
Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8080 -> 0.0.0.0:0: listen tcp 0.0.0.0:8080: bind: address already in use
I checked to see what process is listening on port 8080
netstat -ltnp | grep -w ':8080'
>> tcp6 0 0 :::8080 :::* LISTEN 155621/rootlesskit
I am using docker rootless so I guess it is using port 8080 by default. I tried killing the process but every time I ran docker-compose it is up again. Is there anyway to stop it from using this port by default?
It turns out I have another container using port 8080. After removing it I can now use port 8080 again. My suggestion for anyone encountering the same issue is to check carefully everything with docker images -a and docker container ls. One more important thing to check is also the context in which you run your docker command with docker context ls.
I am new to mqtt and am trying to simply start a local instance with which I can test.
When executing
docker run -it -p 1883:1883 --restart always -v mosquitto.conf:/home/juliette/mosquito.conf --name mqtt eclipse-mosquitto:2.0.7
I get the following output:
1615963221: mosquitto version 2.0.7 starting
1615963221: Config loaded from /mosquitto/config/mosquitto.conf.
1615963221: Starting in local only mode. Connections will only be possible from clients running on this machine.
1615963221: Create a configuration file which defines a listener to allow remote access.
1615963221: Opening ipv4 listen socket on port 1883.
1615963221: Opening ipv6 listen socket on port 1883.
1615963221: Error: Address not available
1615963221: mosquitto version 2.0.7 running
and cannot connect with a mqtt-client:
mqtt sub --topic test
Server closed connection without DISCONNECT.
From what I've found the error apparently happens when no listener is configured but I did configure one, this is my mosquito.conf:
listener 1883
allow_anonymous true
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
port 1883
I also tried changing the port to 8883 because in one post someone mentioned that a larger port might solve the problem but that also didn't work.
Can someone tell me what I'm doing wrong?
Your startup command is close, but not correct. It should be:
docker run -it \
-p 1883:1883 \
--restart always \
-v /home/juliette/mosquito.conf:/etc/mosquitto/mosquitto.conf \
--name mqtt \
eclipse-mosquitto:2.0.7
The config file is in /etc/mosquitto...unless they have moved it in version 2.
You might also want to add a -p 8333:8333 line for mqtts/TLS connections.
EDIT: I see up in your log file output it says that the config was loaded from /mosquitto/config/mosquitto.conf ...so if the -v /home/juliette/mosquito.conf:/etc/mosquitto/mosquitto.conf line does not work, change it to -v /home/juliette/mosquito.conf:/mosquitto/config/mosquitto.conf
I have a HTTP health check in my service, exposed on localhost:35000/health. At the moment it always returns 200 OK. The configuration for the health check is done programmatically via the HTTP API rather than with a service config, but in essence, it is:
set id: service-id
set name: health check
set notes: consul does a GET to '/health' every 30 seconds
set http: http://127.0.0.1:35000/health
set interval: 30s
When I run consul in dev mode (consul agent -dev -ui) on my host machine directly the health check passes without any problem. However, when I run consul in a docker container, the health check fails with:
2017/07/08 09:33:28 [WARN] agent: http request failed 'http://127.0.0.1:35000/health': Get http://127.0.0.1:35000/health: dial tcp 127.0.0.1:35000: getsockopt: connection refused
The docker container launches consul, as far as I am aware, in exaclty the same state as the host version:
version: '2'
services:
consul-dev:
image: "consul:latest"
container_name: "net-sci_discovery-service_consul-dev"
hostname: "consul-dev"
ports:
- "8400:8400"
- "8500:8500"
- "8600:8600"
volumes:
- ./etc/consul.d:/etc/consul.d
command: "agent -dev -ui -client=0.0.0.0 -config-dir=/etc/consul.d"
I'm guessing the problem is that consul is trying to do the GET request to the containers loopback interface rather than what I am intending, which is for the loopback interface of the host. Is that a correct assumption? More importantly, what do I need to do to correct the problem?
So it transpires that there was a bug in some previous versions of macOS that prevented use of the docker0 network. Whilst the bug is fixed in newer versions, Docker support extends to older versions and so Docker for Mac doesn't currently support docker0. See this discussion for details.
The workaround is to create an alias to the loopback interface on the host machine, set the service to listen on either that alias or 0.0.0.0, and configure Consul to send the health check GET request to the alias.
To set the alias (choose a private IP address that's not being used for anything else; I chose a class A address but that's irrelevant):
sudo ifconfig lo0 alias 10.200.10.1/24
To remove the alias:
sudo ifconfig lo0 -alias 10.200.10.1
From the service definition above, the HTTP line should now read:
set http: http://10.200.10.1:35000/health
And the HTTP server listening for the health check requests also needs to be listening on either 10.200.10.2 or 0.0.0.0. This latter option is suggested in the discussion but I've only tried it with the alias.
I've updated the title of the question to more accurately reflect the problem, now I know the solution. Hope it helps somebody else too.
I have configured the mosquitto broker to listen to port 8883 which is the port that will be used for making ssl connections from the mosquitto broker. I restarted mosquitto broker using the following command
mosquitto -v -c mosquitto.conf
I encountered an error:
Only one usage of each socket address is permitted. What is this error and how to solve this error?
The command you have typed is not the command to restart mosquitto.
You can type sudo service mosquitto restart to restart the mosquitto service which by default loads /etc/mosquitto/mosquitto.conf if you're running linux.
The error you have seen has occured because mosquitto service may be already running on port 1883 and you have tried to run mosquitto again on that port.
Better to stop the service or restart it.
To stop mosquitto - sudo service mosquitto stop
Status - sudo service mosquitto status
I am trying to get this fig image here up and running: https://registry.hub.docker.com/u/harbur/sonarqube/
docker and fig installed fine and also the two images boot normally (including the applications - checked from the logs).
however, there should be a port forwarding setup so that I can connect from my host machine to the sonarqube instance. however, I can't connect to the machines as no port is open on the host OS.
Is there anybody who can give me a hint on what I'm doing wrong?
Cheers,
Matthias
$ docker port dockersonarqube_sonarqube_1
443/tcp -> 0.0.0.0:49154
9000/tcp -> 127.0.0.1:9000
$ curl 127.0.0.1:9000
curl: (7) Failed connect to 127.0.0.1:9000; Connection refused
this is the fig config file:
postgresql:
image: orchardup/postgresql:latest
environment:
- POSTGRESQL_USER=sonar
- POSTGRESQL_PASS=xaexohquaetiesoo
- POSTGRESQL_DB=sonar
volumes:
- /opt/db/sonarqube/:/var/lib/postgresql
sonarqube:
image: harbur/sonarqube:latest
links:
- postgresql:db
environment:
- DB_USER=sonar
- DB_PASS=xaexohquaetiesoo
- DB_NAME=sonar
ports:
- "127.0.0.1:9000:9000"
- "443"
If you're using boot2docker on a Mac, you need to access the website via the VM. You'll need to do two things:
Expose the VM port on all interfaces by changing "127.0.0.1:9000:9000" to "0.0.0.0:9000:9000".
Use the IP of the VM to connect to the server e.g. curl $(boot2docker ip 2> /dev/null):9000
You shouldn't need to muck with port forwarding inside the VM unless you really don't like using the boot2docker IP rather than 0.0.0.0.
With boot2docker on OSX you need to set up port forwarding. You need to run something like:
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port9000,tcp,,9000,,9000";
REF: https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md
Also you need to replace 127.0.0.1 by 0.0.0.0 in your fig.yml file in order to have
- "0.0.0.0:9000:9000"