localhost not point to correct ip address in node 18

Nodejs is becoming very popular among developers for backend development. There are lots of resources to learn it. Recently, I faced an issue when I was running my node application. I am using MySQL for the database and use MySQL npm library to connect…


This content originally appeared on DEV Community and was authored by Amit Tiwary

Nodejs is becoming very popular among developers for backend development. There are lots of resources to learn it. Recently, I faced an issue when I was running my node application. I am using MySQL for the database and use MySQL npm library to connect to my database and query data. Before you start doing the query, you need to config the MySQL library and then only it can connect to your database. You must pass the IP address where your database is hosted, user name, and password. I was testing locally, so I ran the MySQL server on my machine and used the localhost as the IP address to connect to it. But I was getting the continuous error that the library was not able to make connection to SQL. After research, I found that I am using node 18 in my system and in node 18 localhost is converted to ipv6 instead of ipv4. So I need to add the IP address of localhost i.e 127.0.0.1 to connect to my local SQL server.


This content originally appeared on DEV Community and was authored by Amit Tiwary


Print Share Comment Cite Upload Translate Updates
APA

Amit Tiwary | Sciencx (2022-07-02T17:53:38+00:00) localhost not point to correct ip address in node 18. Retrieved from https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/

MLA
" » localhost not point to correct ip address in node 18." Amit Tiwary | Sciencx - Saturday July 2, 2022, https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/
HARVARD
Amit Tiwary | Sciencx Saturday July 2, 2022 » localhost not point to correct ip address in node 18., viewed ,<https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/>
VANCOUVER
Amit Tiwary | Sciencx - » localhost not point to correct ip address in node 18. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/
CHICAGO
" » localhost not point to correct ip address in node 18." Amit Tiwary | Sciencx - Accessed . https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/
IEEE
" » localhost not point to correct ip address in node 18." Amit Tiwary | Sciencx [Online]. Available: https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/. [Accessed: ]
rf:citation
» localhost not point to correct ip address in node 18 | Amit Tiwary | Sciencx | https://www.scien.cx/2022/07/02/localhost-not-point-to-correct-ip-address-in-node-18/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.