1
votes

I followed this Git repo

Everything worked fine.

I can be able to issue php artisan varnish:flush from SSH.

but when I tried to flush cache from script i was getting error as

sudo: no tty present and no askpass program specified

This is how I added in routes.php

Route::get('/flush', function() {
    Artisan::call('varnish:flush');
});

and I also Tried

Route::get('/flush', function() {
    (new Spatie\Varnish\Varnish())->flush();
});

This is how complete error looks.

ProcessFailedException in Varnish.php line 64:
The command "sudo varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082 'ban req.http.host ~ (^www.host.com$)'" failed.

Exit Code: 1(General error)

Working directory: /home/admin/web/host.com/public_html

Output:
================


Error Output:
================
sudo: no tty present and no askpass program specified

I am using Vesta CP Over VPS.

Find Me A Solution to solve this error..

1

1 Answers

1
votes

When using sudo the command opens the folder /dev/tty for read-write and prints that error if it fails.

Rebooting your machine would be sufficient to get the folder back if it was removed. The system recreates all devices in /dev during bootup.

Also, make sure the permissions are correct:

chmod 666 /dev/tty