The node requests the API address written by java to report an error error:getaddrinfo ENOTFOUND

1. Questions

The node server requests the java interface with the following code. The local host name in the project is localhost, so it will not report an error, but it will report an error after it is deployed to the formal environment error:getaddrinfo ENOTFOUND :8080

var opt = {
        hostname: '',
        port: '8080',
        method: 'POST',
        path: path,
        headers: {
            "Content-Type": 'application/json;charset=utf-8',

2. Solution

Because the host name only fills in the actual host name, remove the http:// or HTTPS:// in the host name (fill in the specific path in the path), and you can request normally.

Read More: