When trying to connect to mysql server via telnet I am getting following error:

telnet localhost 3306
Trying ::1...
telnet: Unable to connect to remote host: Connection timed out

I tried telnet with, hostname also, but getting same error message. But I can connect with mysql -u username -p once I am in the server.

Here is the result of netstat:

netstat -na | grep mysql
unix  2      [ ACC ]     STREAM     LISTENING     4540495  /var/run/mysqld/mysqld.sock

netstat -na | grep 3306
tcp        0      0  *               LISTEN  

What could be possible problems? If you need some more details I could provide it without any problems.

Thanks a lot.

  • Are you able to provide the output of iptables-save? Can you also try to telnet to the host using the non-localhost IP address of the machine (so, for example Nov 15, 2011 at 21:39

2 Answers 2


Can you connect with:

mysql -h127.0.0.1 -u username -p

If not, check whether your server was started 'skip-networking' enabled:

If the server was started with --skip-networking, it will not accept TCP/IP connections at all. src

Which indicates will not work, but localhost will. In mysql localhost and are different hosts.

Further things to check:

  • are you running the default port (3306)? Check your my.cnf or do mysqladmin -h localhost -p variables | grep port

  • If you are running under Linux and Security-Enhanced Linux (SELinux) is enabled, make sure you have disabled SELinux protection for the mysqld process.

  • mysql -h localhost -u username -p works fine but mysql -h -u username -p says ERROR 2003 (HY000): Can't connect to MySQL server on '' (110)
    – Bakhtiyor
    Nov 15, 2011 at 20:43
  • How to see whether it is started with --skip-networking or not?
    – Bakhtiyor
    Nov 15, 2011 at 20:43
  • If you log in on localhost, do SHOW VARIABLES LIKE 'skip_networking' Nov 15, 2011 at 20:45
  • I have ubuntu and have revised my.cnf for skip-networking parameter. I didn't find any record saying skip-networking.
    – Bakhtiyor
    Nov 15, 2011 at 20:46
  • SHOW VARIABLES LIKE 'skip_networking' is showing skip_networking | OFF |
    – Bakhtiyor
    Nov 15, 2011 at 20:47

I got same problem and i resolved . I use Mac pro & sequel Pro as mysql client , socket localhost connection succeeded but standard tcp/ip Connection failed!
and I check my running port by using cmd :

mysqladmin -h localhost -u root -p variables | grep port

here is my result status:

wangxiaodeMacBook-Pro:~ wangxiao$ mysqladmin -h localhost -u root -p variables | grep port
Enter password: 
| innodb_support_xa                                      | ON                                                                                                                                                                                                                                                                                                                                               |
| large_files_support                                    | ON                                                                                                                                                                                                                                                                                                                                               |
| port                                                   | 3307                                                                                                                                                                                                                                                                                                                                             |
| report_host                                            |                                                                                                                                                                                                                                                                                                                                                  |
| report_password                                        |                                                                                                                                                                                                                                                                                                                                                  |
| report_port                                            | 3307                                                                                                                                                                                                                                                                                                                                             |
| report_user                                            |                       

It's porting 3307 not default 3306 , there was another mysql server installed once . so change it and resolved. tks @DTest 's answer.

  • Welcome to ServerFault. Thank you posting your answer ; although it does not really add al that much more to the already existing answer, especially without proper formatting. To show appreciation please vote up any useful answer and not just say thank you. Hope you stay around will become another active community member.
    – HBruijn
    Sep 10, 2015 at 5:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .