Tomcat6 Solr Typo3 – How to Bind Tomcat to IPv4 Address

solrtomcat6typo3

I recently installed tomcat via an installation script from the apache solr typo3 community and spent the last 3 days trying to figure out why it won't work until by chance I noticed that when I queried the process listening on the port via "lsof -i", it was bound to the ipv6 protocol.

I have googled everywhere and most say that setting address to 0.0.0.0 in the tomcat connector resolves this issue, others say setting JAVA_OPTS="-Djava.net.preferIPv4Stack=true".

I have tried the former which doesn't work but the latter I am unsure of where to put it. One solution I read somewhere suggested to put it in setenv.sh but I can't find this file in my tomcat installation. I would appreciate any help at the moment regarding this.

The tomcat version is 6.x and the OS is ubuntu 11.10.

Thanks

Best Answer

Many suggested updating catalina.sh startup script. Yes, that solution would work, but catalina.sh script is not meant to be customized/updated. All changes should go into the customization script instead, i.e. setenv.sh.

NOTE: TOMCAT_HOME/bin/setenv.sh doesn't exist by default, you need to create it. Check the catalina.sh script and you will see the startup script checks if setenv.sh exists, and executes if it does.

So, I suggest you create new TOMCAT_HOME/bin/setenv.sh script with a single line:

JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true "