Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

root@d92ea67d3f1c:/var/log# curl localhost:3001 <html> <head><title>400 The plain HTTP…

  1. User

    root@d92ea67d3f1c:/var/log# curl localhost:3001

    jackie@TB0807E004:~$ curl 13.239.8.176:3001

    Why cannot curl through public ip?

  2. Assistant

    The error message you are seeing, "400 The plain HTTP request was sent to HTTPS port," indicates that the server at the specified IP and port (at 3001) is expecting a secure HTTPS request but is receiving a plain HTTP request instead.

    When you attempt to access the server using curl on both localhost:3001 and 13.239.8.176:3001, the following points should be considered:

    1. Local Testing: When you curl localhost:3001, it may be running on the server in an environment where HTTPS is enforced. Since you're sending an HTTP request (which is unencrypted), the NGINX server returns a 400 error because it expects the connection to be secured with SSL/TLS.

    2. Public IP Access: Whether or not you receive similar errors when accessing via the public IP address depends on how NGINX is configured to handle incoming requests. If it is still expecting a secure connection on port 3001, the same error will occur.

    Steps to Troubleshoot:

    1. Check NGINX Configuration: Examine the NGINX configuration file (usually located in /etc/nginx/sites-available/ or /etc/nginx/nginx.conf). Check if port 3001 is configured for SSL/TLS by looking for listen 3001 ssl; or any SSL-related settings within server blocks.

    2. Correct the Protocol:

      • If you need to access the service securely, use HTTPS in your curl command as follows:
        curl https://13.239.8.176:3001
        
      • However, if port 3001 is meant for HTTP, ensure that NGINX is listening on the appropriate port without SSL configured.
    3. Firewall or Security Groups: Ensure that there are no firewall rules preventing access to port 3001 from external sources. If you're using cloud services (like AWS, GCP, etc.), check your security groups or firewall settings.

    4. Service Listening on Correct Port: Verify that the application/service is correctly running and listening on port 3001. You can check it by using:

      netstat -tuln | grep 3001
      
    5. Logs: Check the NGINX error logs (/var/log/nginx/error.log) for more details about the requests being denied.

    6. Port Forwarding: If you're behind a NAT or in a local network setup, ensure that the public IP is correctly routed to the local machine hosting the service.

    By addressing these configurations and checks, you should be able to determine the specifics of why the requests are failing and how to correct the situation.