I am using IPFS to store media files with the address on the blockchain. I have had a lot of issues with ports and access. In the code below I have some code partly running but I get an access issue. I think this is related to the API as the IP is set to

Error -

POST 403   (Forbidden)
ClientRequest._onFinish @ request.js:130
(anonymous) @ request.js:62
EventEmitter.emit @ events.js:96
finishMaybe @ _stream_writable.js:504
endWritable @ _stream_writable.js:514
Writable.end @ _stream_writable.js:484
ClientRequest.end @ request.js:273
onend @ _stream_readable.js:499
g @ events.js:165
EventEmitter.emit @ events.js:78
endReadableNT @ _stream_readable.js:920
afterTickTwo @ index.js:27
Item.run @ browser.js:153
drainQueue @ browser.js:123
jenbil.com/:1 Fetch API cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://jenbil.com:3000' is therefore not allowed access. The response had HTTP status code 403. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Code (ReactJS) in class App extends Component { -

 this.IpfsAPI = IpfsAPI('', '5001')

Code in render -

var zstr = 'hello world from Zillerium2'
   this.IpfsAPI.add(new Buffer(zstr), function (err, res){
          if(err || !res) return console.error("ipfs add error", err, res);
            console.log("no issue");
            res.forEach(function(text) {
                   console.log('successfully stored', text.hash);
                 //  console.log('successfully stored', text.path);
                 //  display(file.Hash);
                    var textaddress=text.hash;

I have the IPFS deamon as follows -

root@ubuntu-2gb-nyc2-01:/home/zipfs# ipfs daemon
Initializing daemon...
Adjusting current ulimit to 2048...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip6/::1/tcp/4001
API server listening on /ip4/
Gateway (readonly) server listening on /ip4/
Daemon is ready

Is the API call assigned to this.IpsfAPI wrong? The IP address looks ok.


IPFS CORS needs to be enabled to connect and access through JavaScript Api

$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://example.com\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]"

for reference


And your remote machine, the firewall needs to be opened for the requesting port.

If still it is not connecting means try to connect with multiaddr of the same ipfs daemon.

  • I have the same error and now I have this config. root@ubuntu-2gb-nyc2-01:/home/zipfs/test# ipfs config show { "API": { "HTTPHeaders": { "Access-Control-Allow-Credentials": [ "true" ], "Access-Control-Allow-Methods": [ "PUT", "POST", "GET" ], "Access-Control-Allow-Origin": [ "jenbil.com" ] } }, "Addresses": { "API": "/ip4/", "Gateway": "/ip4/", "Swarm": [ "/ip4/", "/ip6/::/tcp/4001" ] }, – Trevor Lee Oakley May 3 '17 at 13:54
  • Did you enable the port of ipfs daemon running instance? – Seetharaman GR May 3 '17 at 14:35
  • I have this - root@ubuntu-2gb-nyc2-01:/home/zipfs/test# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0* LISTEN 15995/ipfs Does the mean I have it enabled? – Trevor Lee Oakley May 3 '17 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.