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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.