Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have deployed an application on my Tomcat server with JDBC resources defined. What is puzzling me is that I can connect to the database (which is running locally on the server) only using the server's IP. When I change the resource host to localhost (or then MySQL rejects the connection. I don't want to be connection via the server's IP but rather locally.

What do I do?


share|improve this question
Which Operating System? Are you using a firewall? Which interfaces is MySQL listening on? – Chris Lercher Mar 22 '10 at 14:45
That is on Ubuntu. I am using firewall but 3306 is open - I can connect to the MySQL server from outside via the server's IP. The problem is that Tomcat only connects to MySQL using the server's IP and not localhost. – David Mar 24 '10 at 10:50
up vote 0 down vote accepted

MySQL treats localhost connections and connections and '%' connections differently. Your user needs to be granted access specifically to connect to localhost or or both.

share|improve this answer
Will try, thanks! – David Mar 24 '10 at 12:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.