How to access to a Parse Server running on AWS EC2 Ubuntu's localhost?

十年热恋 提交于 2019-12-12 03:34:42

问题


I have an AWS EC2 Instance running Ubuntu.
I have a Parse server on it, running on localhost, port 1337. I've enabled that port in the instance's security group.

I've tried to check if and how can I access to the instance's localhost using the wget command and check if there is a connection or the connection has been refused, and these are the results:

$ wget http://<Public IP>:1337/parse
Connecting to <Public IP>:1337... failed: Connection refused.
$ wget http://<Private IP>:1337/parse
Connecting to <Private IP>:1337... failed: Connection refused.
$ wget http://localhost:1337/parse
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:1337... failed: Connection refused.
$ wget http://<Public DNS>:1337/parse
Resolving <Public DNS> (<Public DNS>)... <Private IP>
Connecting to <Public DNS> (<Public DNS>)|<Private IP>|:1337... failed: Connection refused.

As you can see above, I checked the Public IP, Public DNS and Private IP.
It always said it failed because that the connection refused, and for some reason, even localhost is refused by the server.

How can I make the localhost accessable from outside the internal network of it and access the Parse server?


回答1:


The public IP address generally won't be the same as the private IP address the external interface uses locally. To see the private IP address, you can run:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000
    link/ether 0a:8c:dd:df:8d:ff brd ff:ff:ff:ff:ff:ff
    inet 172.19.240.213/24 brd 172.19.240.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::88c:ddff:fedf:8cff/64 scope link
       valid_lft forever preferred_lft forever

This shows your interfaces: lo, the localhost loopback, is 127.0.0.1. eth0, the external interface, is 172.19.240.213. Note that it's a private IP in the 172.16.0.0/12 block that doesn't get routed out to the internet. AWS applies another layer of NAT that maps the final public IP address to your EC2 instance.

In general, you should follow Vorsprung's advice and simply bind to 0.0.0.0. If you want to bind directly to eth0, you can look up the address like this.




回答2:


Two things

First, you don't say what server is running but alter it so that it is listening on all addresses. Usually this is done by giving 0.0.0.0 as the bind address. After doing this and restarting the server process check with the ss command from a shell on the server:

$ ss -nl|grep 8082
LISTEN     0      100                      :::4040                    :::*     

if the "Local Address:Port" given by ss is 127.0.0.1 then it is only listening on localhost and is not accessible

Next, use the address given by hostname on the server shell in your browser




回答3:


I solved it by using the public IP of the EC2 instance and the I was able to access the Parse server running on it.



来源:https://stackoverflow.com/questions/36287799/how-to-access-to-a-parse-server-running-on-aws-ec2-ubuntus-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!