Public IPFS node on AWS Ligthsail

I am running into the following problem setting up a IPFS node on an AWS Lightsail instance.

The steps:

(1) Launch a ubuntu 16.4 instance, download and install go-ipfs.

(2) Edit the config file to change the IP from 127.0.0.1 to 0.0.0.0:

"API": "/ip4/0.0.0.0/tcp/5001",
"Gateway": "/ip4/0.0.0.0/tcp/8080"

(3) Open port 8080 and 5001 from the AWS control panel.

(4) Start ipfs daemon

Initializing daemon...
go-ipfs version: 0.4.20-
Repo version: 7
System version: 386/linux
Golang version: go1.12.4
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.26.8.175/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/0.0.0.0/tcp/5001
WebUI: http://0.0.0.0:5001/webui
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
Daemon is ready

I can now access IPFS content from [PUBLIC IP]:8080/ipfs/Qm....

Great! But what I am actually looking to do is access the API over port 5001.

Trying this from a node app running on my local machine like so:

const ipfs = ipfsAPI({ host: '[PUBLIC IP]', port: '5001' })

I get this error:

 { Error: connect ETIMEDOUT [PUBLIC IP]:5001
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '[PUBLIC IP]',
  port: 5001 }

Any idea what I am doing wrong here? Is there some additional config I need to do to make the API accessible remotely?

Grateful for any help!

1 Like

That really should work but please don’t open up the API to the world like that. It’s not designed to be a public interface.

However, to debug, try running curl http://YOUR_IP:5001/version.

1 Like

Thanks a lot for the reply @stebalien! It is a temporary arrangement to troubleshoot some issues I am having with the infura API…

Oddly enough the request to http://YOUR_IP:5001/version times out.

curl http://YOUR_IP:8080/version return the version though:

Commit: 
Client Version: go-ipfs/0.4.20/
Protocol Version: ipfs/0.1.0

Could you run sudo lsof -P -n -iTCP:5001 on the machine running IPFS to make sure it’s listening on 0.0.0.0?

It seems to:

COMMAND   PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
ipfs    23776 ubuntu   18u  IPv4 4628148      0t0  TCP *:5001 (LISTEN)