Smack to ejabberd failed

I tried to use Smack to connect a ejabberd server(locally installed), but failed.

  1. My hosts on ejabberd config:

{hosts, [“macbook.local”, “public.macbook.local”]}.

  1. My Smack client connection:

Connection connection = new XMPPConnection(“macbook.local”);
connection.connect();
connection.login(username, pwd);

It failed on connection.connect(), and the error msg say, “”. Could not connect to macbook.local:5222.: remote-server-timeout(504) Could not connect to macbook.local:5222.
– caused by: java.net.UnknownHostException: macbook.local

I tried localhost, and it failed too.

Any idea?
Thanks in advance.