You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS下Vagrant虚拟机中Aerospike Java客户端连接失败求助

Fixing Aerospike Java Client Connection Issues with Vagrant-deployed Instance on macOS

Let's break down why your Java client can't connect to your Aerospike instance, and how to fix it quickly:

First, the Core Issue: Wrong Port!

You're using port 8081 in your client code—that's the port for the Aerospike Management Console (AMC), which is exactly why you can access AMC without problems. The default port for Aerospike database client connections is 3000.

Step 1: Correct the Client Port in Your Code

Update your AerospikeClient initialization to use the proper database port:

new AerospikeClient("172.28.128.3", 3000);

Step 2: Verify Vagrant Port Forwarding (If Needed)

If you still can't connect after fixing the port, double-check your Vagrant port forwarding setup:

  • Open your Vagrantfile and look for a line like this:
    config.vm.network "forwarded_port", guest: 3000, host: 3000
    
  • If it's missing, add that line, then run vagrant reload to restart your instance.
  • You can also connect using localhost:3000 from your Mac host if port forwarding is set up:
    new AerospikeClient("localhost", 3000);
    

Step 3: Ensure Aerospike is Bound to the Correct Address

Sometimes Aerospike is configured to only listen on localhost inside the Vagrant VM, blocking external connections:

  1. SSH into your Vagrant instance: vagrant ssh
  2. Edit the Aerospike config file (typically at /etc/aerospike/aerospike.conf)
  3. Find the network > service section and make sure the address is set to any or the VM's IP (172.28.128.3):
    network {
        service {
            address any
            port 3000
        }
    }
    
  4. Restart the Aerospike service: sudo systemctl restart aerospike

Step 4: Test Network Connectivity

From your Mac host, test if the port is reachable using telnet or nc:

# Using telnet
telnet 172.28.128.3 3000

# Or using netcat
nc -zv 172.28.128.3 3000

If the connection succeeds, the network path is good—focus on client code or configuration. If it fails, double-check Vagrant network settings and any firewall rules inside the VM.

内容的提问来源于stack exchange,提问作者user27111987

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:52:17