Unable to reach GCP VM Instance via external IP despite successful start of apache2

According to the instructions provided in this document (https://cloud.google.com/community/tutorials/setting-up-lamp), I am unable to access via the external IP address. Could you please provide me with some suggestions? Thank you.
=================================
When I use the command “curl –head http://35.240.177.89/”, I receive an error message stating “Failed to connect to 35.240.177.89 port 80: Operation timed out”. Similarly, when I use the command “curl –head https://35.240.177.89/”, I receive the error message “Failed to connect to 35.240.177.89 port 443: Operation timed out”.
The output of the command “netstat -lntup” is as follows: [result].
To resolve this issue, assuming that your Linux system has dual stack enabled, the netstat output indicates that Apache2 is listening on both IPv4 and IPv6 port 80 for all network interfaces. I connected to my instance using SSH, ran the jar file, and now my application can be accessed externally using the IP address and port.

Question:

I’ve set up a test
vm instance
on GCP.

  • Successfully install apache2 and start the service.
  • The firewall setup is set to the
    firewall setup
    by default.
  • The configuration of Apache ports: port settings.
  • external ip
    :
    External IP

Although the document at https://cloud.google.com/community/tutorials/setting-up-lamp states that everything is fine, I am unable to access
external IP
.

I would appreciate any suggestions you can provide. Thank you.

=================================

The connection to 35.240.177.89 failed (
curl –head
). The error message displayed was: “curl: (7) Failed to connect to 35.240.177.89 (
port 80
):
Operation timed
out”.

When using the command “curl –head https://35.240.177.89/”, there was a failure to connect to the IP address 35.240.177.89 on port 443, resulting in an operation timeout.

netstat -lntup:
result


Solution:

If your Linux system has
dual stack
enabled, the netstat command with

:::80

indicates that Apache2 is listening on port 80 for both IPv4 and IPv6 on all network interfaces. To confirm this, you can use the following command. A

0

value signifies that dual stack is enabled.

cat /proc/sys/net/ipv6/bindv6only

Considering the information provided, it is probable that your system lacks a rule for

iptables

to permit port 80. If you are using Ubuntu 18.04 (adjust for your specific distribution), please make the necessary modifications.

Ensure the rules of

iptables

are backed up.

sudo iptables-save > iptables.backup

Allow ingress port 80:

sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT

Optionally allow ingress port 443:

sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT

Frequently Asked Questions