Can browse to localhost, but not to hostname or ip

I installed AcitveMQ in a LXD container. I can curl to local host from within the LXD container

[root@centos8 activemq]# curl http://localhost:8161

Error 401 Unauthorized

HTTP ERROR 401 Unauthorized

URI: /
STATUS: 401
MESSAGE: Unauthorized
SERVLET: -

Powered by Jetty:// 9.4.39.v20210325

But I can not connect to its ip.

[root@centos8 activemq]# curl http://10.18.217.146:8161
curl: (7) Failed to connect to 10.18.217.146 port 8161: Connection refused

I can not curl to it from the host either

Karl@Nordström ~:$ curl http://10.18.217.146:8161
curl: (7) Failed to connect to 10.18.217.146 port 8161: Connection refused

Karl@Nordström ~:$ lxc list centos8
±--------±--------±---------------------±-----±----------±----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
±--------±--------±---------------------±-----±----------±----------+
| centos8 | RUNNING | 10.18.217.146 (eth0) | | CONTAINER | 0 |
±--------±--------±---------------------±-----±----------±----------+

firewalld, iptables and nftables are not installed.

Does CentOS 8 block some network traffic by default?

It could be firewalling or it could be that ActiveMQ out of the box only listens on the localhost address and that you need to configure it to listen on something else (like 0.0.0.0 or :: for all addresses).

Running something like ss -tlpn inside the container will show you if the service is listening on an external address.

I changed the host name value in a jetty.xml file from 127.0.0.1 to 0.0.0.0

[root@centos8 activemq]# less /opt/local/activemq/conf/jetty.xml

<bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
         <!-- the default port number for the web console -->
    <property name="host" value="127.0.0.1"/>
    <property name="port" value="8161"/>
</bean>

to match our dev host.

[kxn2@amq-d01 ~]$ less /opt/local/activemq/conf/jetty.xml

and restart activemq service and now it works.

Thanks for your help

1 Like

before my config change

LISTEN 0 50 [::ffff:127.0.0.1]:8161

after my change

LISTEN 0 50 *:8161