# Failed to open stream: Permission denied

**URL:** <https://community.dreamfactory.com/t/failed-to-open-stream-permission-denied/2421>\
**Category:** Connecting to File Storage\
**Created:** [March 28, 2016, 6:56am UTC](https://community.dreamfactory.com/t/failed-to-open-stream-permission-denied/2421 "2016-03-28T06:56:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrjohny](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mrjohny](https://community.dreamfactory.com/u/mrjohny)\
**Post date:** [March 28, 2016, 6:56am UTC](https://community.dreamfactory.com/t/failed-to-open-stream-permission-denied/2421/1 "2016-03-28T06:56:55Z")

</div>

Hello,

Because this topic isn’t yet covered here, i thought i might help people in the future. I’ve upgraded my dreamfactory platform (in this case from 2.0.1 to 2.1.x) and after this my file upload wasn’t working anymore. I received the following error in my console:

`file_put_contents(/opt/DF2/apps/dreamfactory/htdocs/storage/app/R90/1459147362758hnaMgCkWyFhK9vxqmNVjqYUdvdSoCgJ3VK1hDizSw2BvuvIch5R7FDhx5CVnftd8.gif): failed to open stream: Permission denied`

I didn’t change anything on the roles, and the file service was setup fine. After searching for a solution, I came acros this post: [http://stackoverflow.com/questions/23540083/failed-to-open-stream-permission-denied-error-laravel](http://stackoverflow.com/questions/23540083/failed-to-open-stream-permission-denied-error-laravel)

Based on the suggestion there the following fixed my issue:

> ```
> php artisan cache:clear 
> chmod -R 777 opt/DF2/apps/dreamfactory/htdocs/storage/app
> 
> ```

The last part didn’t work for me but wasn’t needed as well (it seems)

> composer dump-autoload

---

<div class="post-metadata">

**Author:** ![formerstaff](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/formerstaff/32/1133_2.png) [@formerstaff](https://community.dreamfactory.com/u/formerstaff)\
**Post date:** [March 28, 2016, 12:36pm UTC](https://community.dreamfactory.com/t/failed-to-open-stream-permission-denied/2421/2 "2016-03-28T12:36:07Z")

</div>

If an upgrade includes changes to the cache or storage directories, the clone from github will mess with the permissions there, and the web server can no longer write to these directories.  
To correct this you should run the following

`sudo chown -R {web-server-user}:{your-user-group} storage/ bootstrap/cache/ sudo chmod -R 2775 storage/ bootstrap/cache/`

Insert the values specific to your environment in the user and group.  
For example, in my Ubuntu machine, where my user name is drew, and I’m running Apache, that command would be:  
`sudo chown -R www-data:drew storage/ bootstrap/cache/`

The default Apache user for debian based distros is www-data, and the defaul Apache user for RHEL/CentOS distros is apache.  
For Bitnami cloud images, the Apache user is usually daemon.

After this operation clear the cache (as mentioned above) and restart the web server.

---

<div class="post-metadata">

**Author:** ![mrjohny](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mrjohny](https://community.dreamfactory.com/u/mrjohny)\
**Post date:** [March 28, 2016, 8:21pm UTC](https://community.dreamfactory.com/t/failed-to-open-stream-permission-denied/2421/3 "2016-03-28T20:21:31Z")

</div>

Ok, so I followed your instructions, but now I have some bigger issues…

When restarting the machine and starting the services by using …/…/…/ctlscript.sh restart

I’m getting

```
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
/opt/DF2/apache2/scripts/ctl.sh : httpd could not be started
```

---

<div class="post-metadata">

**Author:** ![jason.gilmore](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jason.gilmore](https://community.dreamfactory.com/u/jason.gilmore)\
**Post date:** [April 17, 2020, 5:31pm UTC](https://community.dreamfactory.com/t/failed-to-open-stream-permission-denied/2421/4 "2020-04-17T17:31:47Z")

</div>

This is a common error associated with running multiple servers on a single machine. Note the beginning of the error “Address already in use”. If you’re running multiple development servers, then the first one started is likely to run on port 80. If like me you often have multiple terminal tabs open it’s not always easy to remember which application is running on a specific port. You can use commands like `lsof` to learn more about the command that used the port. For instance in the following example I’m passing port `8080` to `lsof`, and can see that a NodeJS server is using the port:

```
$ lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 90692 wjgilmore 14u IPv4 0x41500bb50c0a1f2d 0t0 TCP *:http-alt (LISTEN)

```

Many tools such as Laravel’s `serve` command support specifying a port at start time:

`$ php artisan --port 8001`
