How do I configure this property with Spring Boot and an embedded Tomcat?

I prefer set of system properties before the server start:

 * Start SpringBoot server
@SpringBootApplication(scanBasePackages= {"com.your.conf.package"})
//@ComponentScan(basePackages = "com.your.conf.package")
public class Application {
    public static void main(String[] args) throws Exception {
        ApplicationContext ctx =, args);

Spring Boot 1.4 and later

As of Spring Boot 1.4 you can use the property server.connection-timeout. See Spring Boot's common application properties.

Spring Boot 1.3 and earlier

Provide a customized EmbeddedServletContainerFactory bean:

public EmbeddedServletContainerFactory servletContainerFactory() {
    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();

    factory.addConnectorCustomizers(connector -> 
            ((AbstractProtocol) connector.getProtocolHandler()).setConnectionTimeout(10000));

    // configure some more properties

    return factory;

If you are not using Java 8 or don't want to use Lambda Expressions, add the TomcatConnectorCustomizer like this:

    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
        public void customize(Connector connector) {
            ((AbstractProtocol) connector.getProtocolHandler()).setConnectionTimeout(10000);

The setConnectionTimeout() method expects the timeout in milliseconds (see connectionTimeout in Apache Tomcat 8 Configuration Reference).