If you have installed Tomcat 8 on your linux server and it is taking forever to (re)start, it is not your fault. It happens when Java Runtime Environment (JRE) entropy source is short of entropy. Tomcat 8+ relies on SecureRandom class to provide randomly generated values for its session ids and in other places. JRE can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy.

In order to fix this issue, you need to replace the blocking entropy source with a non-blocking source in $JAVA_PATH/jre/lib/security/java.security file. Depending on your installation of Java (headless JRE, Oracle Java, OpenJDK ...), $JAVA_PATH can be different. In my case (Java 8 OpenJDK on Ubuntu 18.04), it is /usr/lib/jvm/java-8-openjdk-amd64.

$ nano /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security

Find the line with securerandom.source=file:/dev/random text and change it to securerandom.source=file:/dev/./urandom. Save the file and restart Tomcat 8. That's it.

You can also fix this issue by setting the following system property which will configure the JRE to use a non-blocking entropy source.

-Djava.security.egd=file:/dev/./urandom
🙌 Join the weekly newsletter and get the latest tutorials from my blog and around the internet.
No spam, ever. You can unsubscribe anytime.

Follow @attacomsian on Twitter to stay up-to-date with posts on this blog. You can also follow me on LinkedIn and DEV.


Need help to start a new Spring Boot or MEAN stack project? I am available for contract work. Hire me to accomplish your business goals with engineering and design. Let’s talk about your project: hi@attacomsian.com.