Connection timed out when connecting to ldap

ldap connection timeout
root exception is java net connectexception connection refused: connect
java net connectexception connection timed out: connect
com sun jndi ldap connect timeout
intermittent ldap authentication
ldap communication exception
javax naming partialresultexception root exception is javax naming communicationexception
java net connectexception connection refused: connect in eclipse

i am trying to connect to ldap active directory on windows server 2008 using spring ldap 1.3.1.RELEASE and ldap config is as follows:

  • ldap url is: ldap://
  • username: administrator
  • password: 123456

- spring ldap configuration is as follows:

    <bean id="contextSource" 
    <property name="url" value="ldap://" />
    <property name="base" value="dc=fabrikam,dc=com" />     
    <property name="userDn" value="CN=administrator,CN=Users,DC=fabrikam,DC=com" />     
    <property name="password" value="123456" />

    <property name="baseEnvironmentProperties">
        <entry key="java.naming.referral">


<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <constructor-arg ref="contextSource" />
  • LDAPContactDAO:

    public class LDAPContactDAO implements ContactDAO {
    private LdapTemplate ldapTemplate;
    public List getAllContactNames() {
        return"", "(objectclass=person)",
                new AttributesMapper() {
                    public Object mapFromAttributes(Attributes attrs)
                            throws NamingException {
                        return attrs.get("cn").get();

-debugs before the exception:

2012-12-31/15:50:36.425 [localhost-startStop-1] DEBUG AuthenticationSource not set - using default implementation
2012-12-31/15:50:36.428 [localhost-startStop-1] DEBUG Not using LDAP pooling
2012-12-31/15:50:36.428 [localhost-startStop-1] DEBUG Trying provider Urls: ldap://,dc=com
2012-12-31/15:50:37.558 [http-bio-8080-exec-5] DEBUG Got Ldap context on server 'ldap://,dc=com'

when trying to use the getAllContactNames method, i am getting the following exception:

org.springframework.ldap.CommunicationException:; nested exception is javax.naming.CommunicationException: [Root exception is Connection timed out: connect]
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
javax.servlet.http.HttpServlet.service( Connection timed out: connect
    at Method)
    at com.sun.jndi.ldap.Connection.createSocket(
    at com.sun.jndi.ldap.Connection.<init>(
    at com.sun.jndi.ldap.LdapClient.<init>(
    at com.sun.jndi.ldap.LdapClient.getInstance(
    at com.sun.jndi.ldap.LdapCtx.connect(
    at com.sun.jndi.ldap.LdapCtx.<init>(
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(
    at com.sun.jndi.url.ldap.ldapURLContextFactory.getObjectInstance(
    at javax.naming.spi.NamingManager.getURLObject(
    at javax.naming.spi.NamingManager.processURL(
    at javax.naming.spi.NamingManager.processURLAddrs(
    at javax.naming.spi.NamingManager.getObjectInstance(
    at com.sun.jndi.ldap.LdapReferralContext.<init>(
    at com.sun.jndi.ldap.LdapReferralException.getReferralContext(
    at com.sun.jndi.ldap.LdapCtx.searchAux(
    at com.sun.jndi.ldap.LdapCtx.c_search(
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(
    at org.springframework.ldap.core.LdapTemplate$4.executeSearch(
    at com.xeno.advancedphonedirectory.LDAPContactDAO.getAllContactNames(
    at com.xeno.advancedphonedirectory.web.IndexController.get(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(
    at org.springframework.web.servlet.DispatcherServlet.doService(
    at org.springframework.web.servlet.FrameworkServlet.processRequest(
    at org.springframework.web.servlet.FrameworkServlet.doGet(
    at javax.servlet.http.HttpServlet.service(
    at javax.servlet.http.HttpServlet.service(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.valves.AccessLogValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.http11.AbstractHttp11Processor.process(
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
    at java.util.concurrent.ThreadPoolExecutor$

please advise.


I managed to connect to active directory with jxplorer using the following configuration:

  1. Host:
  2. Port: 389
  3. Base DN: dc=fabrikam,dc=com
  4. User DN: CN=administrator,CN=Users,DC=fabrikam,DC=com
  5. Password: secret

but i still getting timeout with spring ldap connection.


the issue is now narrowed to spring ldap because i tried the above configuration with JNDI and connection to ldap works fine as mentioned in here:

ldap search is very slow

i think that the referral property might be the issue.

We found this issue was due to a non-existent domain controller in DNS. If you're using a domain name instead of IP, do an NSLOOKUP to show all the IPs the domain points to:


Ensure all the IPs from NSLOOKUP are reachable on port 389:

Test-NetConnection -port 389

AD To OID Sync Fails With [Root exception is , AD To OID Sync Fails With [Root exception is Connection timed out] (Doc ID 433018.1). Last updated on OCTOBER 02, Now ActiveChgImp.trc file shows error connecting to AD server: LDAP URL : (<AD HOSTNAME>:<AD LDAP CommuncationException javax.naming. 2748383-AS Java User Management - No connection to the ldap server - Connection timed out to HTTP Proxy - Best Practices for Investigation Symptom During datasource configuration in Application Server (AS) Java User Management (UME), while trying to make LDAP over SSL (LDAPs) connection between SAP Portal and LDAP server, connection fails due

LDAP Connection TimeOut Exception, CommunicationException: [Root exception is​ConnectException: Connection timed out: connect] at com.sun.jndi.ldap.​Connection. From next time I am not able to connect back to the LDAP directory. It throws follwoing exception for me Caused by: javax.naming.CommunicationException: [Root exception is Connection timed out: connect] at com.sun.jndi.ldap.Connection.<init>(

Solved: Active Directory Users Cannot Login, CommunicationException: advisors.lan:389 [Root exception is​ConnectException: Connection timed out: connect]] at com.atlassian.crowd.​directory. searchEntitiesWithRequestControls(​) <IP of server> <host name of server> You need to have local administrator rights on the machine hosting JIRA to make these changes. Alternatively, you can use the IP of the server in the LDAP configuration, as in Connecting to an LDAP Directory .

The problem you have is the connection you just have to group these aumetnar seeping into the base, for example your configuration is:

<property name="base" value="dc=fabrikam,dc=com" />

change to:

<property name="base" value="ou=grupo,dc=fabrikam,dc=com" />

Question: Getting Connection Timed out Error while Retrieving , Connection timed out when connecting to ldap - spring. LdapCtx.connect( at com.sun.jndi.ldap.LdapCtx. Error: javax.naming.CommunicationException: [server]:[port] [Root exception is Connection refused: connect] Cause: The port name you have specified for the LDAP/AD server is incorrect. I'd say your using the wrong hostname, the wrong port number, or haven't started you LDAP installation on that server yet. Connection timed out: connect · Issue , CommunicationException: [Root exception is​ConnectException: Connection timed out: connect] at com.sun.jndi.ldap. [ERROR: Connection timed out: no further information] This tends to signify an issue on our end, if you see this please contact an administrator to notify management. This issue could be related to your internet connection or could indicate that we are having availability issues

Decision Center Connection to LDAP throws , Connection.(Unknown Source) at com.sun.jndi.ldap.LdapClient.​ConnectException: Connection timed out: connect #1396. Closed. Exception that is thrown on client side is : connection timed out : connect What is the reason and how can i solve this? On client machine these are the following .class files AddClient.class AddServerImpl.class AddServerImpl_Stub.class and on server side AddServer.class AddServerImpl.class AddServerImpl_Stub.class

2748383 - AS Java User Management, CommunicationException: [Root exception is​ConnectException: Connection timed out (Connection timed out)]. at com.sun.jndi​.ldap. Caused by: Connect with us. Connection timed out indicates that the port 389 is not accessible from your network. Make sure the firewall in cloud allows your ip to access port 389 of the LDAP host. phpldapadmin will work since it will listen on port 80/443 and it in turn connects with LDAP locally. You can test the connectivity by running telnet <LDAP Host> 389.

  • Have you tried removing the :389 at the end of the URL in the second example? Your first example was not supplying the full admin DN, so the authentication attempt was being rejected. The second example appears to be unable to connect to the LDAP server.
  • @ig0774, can you please see the latest update ? also is it possible that i can connect to the ldap url from browser ?
  • Connect to an LDAP URL from a web browser? None I know of support that. However, you can use an LDAP browser, such as Apache Directory Studio or JXPlorer to try the LDAP url.
  • Regarding the update, I notice this is what it's trying to connect to: This looks more like a copy-paste issue in the example provided. As I suggested before, could you try changing the url property to ldap:// (or it's un-obfuscated equivalent)?
  • @ig0774, i removed the port suffix and still getting same error, i updated the question again.
  • Great answer, I found the exact IP after "NSLOOKUP" then the connection was established properly.
  • when i use the command telnet 389 there is no response in the cmd
  • @Marcel , how do I check that port is open on server or not?
  • Incomprehensible. 'Group these aumetnar seeping into the base' is meaningless and contains a non-existent word.