title: Spring Boot and Eureka: ConnectTimeoutException: Connect to localhost:8761 timed out
body: <p>After changing the Eureka port number from default port to custom port, when running the Eureka client it is showing following error:</p>
  <pre><code> Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out
              at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar:4.5.6]
              at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar:4.5.6]
              at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
          
      eureka.client.registerWithEureka=true
      eureka.client.fetchRegistry=true
      
  </code></pre>
  <p>This is <strong>application.properties</strong> file content:</p>
  <pre class="lang-ini prettyprint-override"><code>    # serivce name
      spring.application.name=student-service
      # port
      server.port=6161
      # eureka server url
      eureka.client.service-url.defaultZone=http://localhost:6969/eureka
      eureka.client.registerWithEureka=true
      eureka.client.fetchRegistry=true
      
  </code></pre>
  <p>it is showing</p>
  <pre><code>com.sun.jersey.api.client.ClientHandlerException: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761
  </code></pre>