Unable to Connect to TiDB on Local Area Network

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TiDB局域网无法连接

| username: wangccsy

To improve efficiency, please provide the following information. A clear problem description will help resolve the issue faster:

[Overview] I installed TiDB 7.5.0 on a virtual machine and it started successfully, as shown in the image:


I used VMWare’s NAT port mapping to map port 4000 to the host, as shown in the image:

I can telnet to port 4000 on the host, but I can’t connect using MySQL WorkBench. Why?

[Application Framework and Development Adaptation Business Logic]

[Background] Connecting using the mysql command within the virtual machine works fine.

[Phenomenon]

[Problem] Unable to connect from outside the virtual machine.

[Business Impact]

[TiDB Version]

[Attachments] Relevant logs and monitoring

| username: zhanggame1 | Original post link

Install a mysql-client in the virtual machine and try connecting using the command line first.

| username: wangccsy | Original post link

A virtual machine can definitely connect. I mentioned in the “[Background] Using the mysql command in the virtual machine connects normally.”

| username: Kongdom | Original post link

:thinking: Is it possible that the cluster IP cannot use 127.0.0.1 and must use the assigned IP?

| username: zhanggame1 | Original post link

I use a virtual machine, so it’s 127.0.0.1. You can connect using other IPs.

| username: forever | Original post link

Can you try connecting using the physical machine’s IP?

| username: zhanggame1 | Original post link

Connecting to the NAT address of the virtual machine on the physical machine

| username: zhanggame1 | Original post link

There is no problem with the NAT forwarding configuration. By the way, have you checked if the firewall is turned off?

| username: 像风一样的男子 | Original post link

When installing the database, you shouldn’t set the configuration file to 127.0.0.1; it should be the 192 IP address. Ports listening on 127.0.0.1 can only be accessed by the local server.

| username: zhanggame1 | Original post link

Actually, it doesn’t matter. All IPs of the virtual machine can be accessed using port 4000, which is unrelated to the deployment.

| username: 连连看db | Original post link

In NAT mode, port forwarding works fine. However, if using bridge mode, you can’t use 127.0.0.1; you need a specific IP to access it.

| username: wangccsy | Original post link

I can ping the virtual machine IP, but cannot telnet to port 4000. It seems to be an issue with listening on 127.0.0.1, right?

| username: wangccsy | Original post link

The firewall is turned off. I can ping, but I can’t telnet. Could it be related to the basic service I created using tiup playground? I didn’t create a cluster. I’m a beginner, still learning.

| username: zhanggame1 | Original post link

There is no need for tiup playground, just build the minimal setup directly TiDB Quick Start Guide | PingCAP Documentation Center

This minimal setup requires a virtual machine with more than 10GB of memory. If you want a smaller setup, configure only one tikv in the parameter file.

| username: wangccsy | Original post link

There is no such high configuration hardware (virtual machine).

| username: 春风十里 | Original post link

Normally, 127.0.0.1 is a local loopback address and cannot provide external services. You can try using a virtual NAT method to relay services. For local single-machine deployment, generally, a memory exceeding 10G is sufficient. You can use an IP address configuration for local single-machine deployment, which makes it easier to provide external services without having to study virtual machine network issues.

| username: TIDB-Learner | Original post link

It should be for this reason. If the topology deployment file specifies 127.0.0.1, it cannot be accessed from non-local machines.

| username: Jellybean | Original post link

Try configuring with the local IP address and see if it resolves the issue.

| username: TIDB-Learner | Original post link

An idea to get the network working

| username: wangccsy | Original post link

The key issue is that I couldn’t find the configuration file to modify the IP address. Is this still MySQL, because there is no my.cnf configuration file?