40

I'm using google scripts to deploy a web app. I've done about 5-10 in the same account. When I try and run the web app/script, I'm now getting: a "Google Drive: Page not found" in the title and the message

Sorry, unable to open the file at this time. Please check the address and try again.

I published it to run as the owner, but accessible to "Anyone, even anonymous".

I then tried creating a new small project with a doGet() method that returns a small static web page, with the same result.

Code.gs:

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('Test');
}

Test.html:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    This is a test
  </body>
</html>

I tried publishing the same spreadsheet/code above in my personal account and it works fine. Since I already have some web apps deployed with the account that's having the error, is there a quota on the number of web apps per account?

I tried a different browser, a different account, re-publishing, and logging out and back in. Same error message. The "Test your web app with the latest code" link also fails. I can directly call the doGet() method in the IDE and it works fine, and I see output in the logs.

I don't see anything in the logs for the page not found error, which is what I expect with the page not found - not even getting to code execution, thus no logs.

Kos
  • 4,890
  • 9
  • 38
  • 42
Douglas Russell
  • 513
  • 1
  • 4
  • 5

6 Answers6

82

I think you are logged in with two gmail account: That is why (/u/1,/u/0) may have been appended to script address (may be a bug).

So what you have to do is remove /u/0 or whatever is appended.

ForExample:

https://script.google.com/macros/u/1/s/ffffsdds/exec becomes https://script.google.com/macros/s/ffffsdds/exec

Community
  • 1
  • 1
imox
  • 1,544
  • 12
  • 12
  • This was exactly it for me as well. I removed the `/u/0` and everything is working as expected now. Really glad I found this because other googling was failing me! – Ben McCormack Nov 15 '17 at 02:36
  • I am glad that you found it Ben. I haggled with it for one day then suddenly saw /u/0 and realized. – imox Nov 15 '17 at 03:41
  • 4
    moving the /u/0 didn't work form me but signing out of all other accounts did – GeorgeButter Dec 09 '17 at 23:59
  • Are you sure that you removed /u/0 without accidentally deleting some characters. Glad you found an answer anyways. Root cause seems to be same, though :-) – imox Dec 10 '17 at 04:14
  • 1
    Is there a way to get deploy as webapp to remove the /u/0? – Cooper Feb 20 '18 at 16:37
  • Thanks! I had to actually copy the URL quickly before it redirected, and edit it from there. – Tim Malone Mar 06 '19 at 08:37
  • 2
    When I delete /u/0 it been append in the url and I'm not able to remove it – Ossarotte Mar 05 '21 at 09:52
  • See this other answer https://stackoverflow.com/a/65139917/370407 for a URL that works regardless of how many Google accounts you are logged into – Mike Eng Jun 21 '21 at 17:47
  • I logged out of every account, then it worked. – Shad Apr 26 '22 at 03:31
13

I have several Gmail accounts open at once and kept having this problem. I found it helped to close the Drive window, log out of the email account related to it, and then log back into the Gmail account and open Drive again.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jennie Harborth
  • 131
  • 1
  • 2
10

You need to add your organization domain to the URL, as in https://script.google.com/a/yourdomain.com/macros/s/ffffsdds/exec - note that a/domain.com has been added. If you're not using a custom domain, use a/gmail.com.

It works when you are logged in to multiple accounts and redirects to https://script.google.com/macros/s/ffffsdds/exec when you are not logged-in to the particular domain account.

Background info:

  1. https://script.google.com/macros/u/1/s/ffffsdds/exec - does not work if you are logged-in with multiple accounts

  2. In https://script.google.com/macros/s/ffffsdds/exec - "/u/x" has been removed but if you visit that URL, it will still redirect to https://script.google.com/macros/u/1/s/ffffsdds/exec and (1) problem remains when you are logged into multiple accounts (however it works if you are not).

Dharman
  • 30,962
  • 25
  • 85
  • 135
user1749939
  • 221
  • 2
  • 6
  • your final solution helped me very much. Could you explain the `/a/yourdomain.com` ? – Radek Feb 18 '21 at 20:54
  • 2
    Many Google accounts are bind to custom domains (product Google Workspace). One person can be logged in with multiple accounts using the same or different domains (including gmail.com). If the script is owned by a custom user account it needs to be accessed with (3) including the custom domain in the URL. – user1749939 Feb 20 '21 at 19:17
  • This should be the accepted answer from a developer point of view. This allows the script URL to work regardless of how many Google accounts the end user is logged into. – Mike Eng Jun 21 '21 at 17:46
  • I am struggling with this too - multiple gmail accounts and page not found when I try to test my deployed app with a different one to the account used to develop the web app. I am trying to follow the above solution but cannot. Which domain should be used - the users or the developers, and should "gmail.com" be a constant or an actual email address? I am editing the deployed app in the address/location bar but every time it ignores my edits and corrects back to the "/u/x". Any help? – Jim Burke Dec 29 '21 at 00:38
2

It looks like it's related to this issue: https://issuetracker.google.com/issues/69270374. Authentication is broken for multiple signed-in accounts.

As Google developers suggests, you should:

  1. Signing out of all accounts and using only 1 account: or
  2. Using an incognito tab to sign in

source (comment 292).

What is sad is that, as they said:

The issue originally reported is due to recent improvements in Sheets' ability to handle multiple logged in accounts.

source (comment 11)

So by improving multiple logged in accounts, they also broke it.

Now the "good" news: we can expect this to be fixed in about 1 year I would say.

Our team plans to begin to work on multi-login support for the new Apps Script IDE and container-bound scripts in Q3 ‘21.

source (comment 292)

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
Paul Laffitte
  • 150
  • 3
  • 12
1

All the above answers are relevant. But for me, the issue was due to lack of space in Google account. I've used all 15GB space provided by Google and then all my Google Forms started showing the above error.

Solutions are:

  1. Buy extra space from Google, it wont cost much. For 100GB, it costs Rs.130/month or Rs.1300/year
  2. Free up your space. Go through the Google Drive and you may find a lot of unwanted files. Delete it and make some free spaces.
0

I had this issue where I was NOT logged in on multiple accounts. What ended up being the issue for me was that I was using LockService, and it seemed to have gotten corrupted somewhere.

I added

const lock = LockService.getScriptLock();
lock.releaseLock();

before my doPost function, which logs had shown was failing to execute. That seemed to fix the issue. I could then remove this snippet from my code and it continued to work.

Adding this in case someone else has this issue and doesn't want to spend several days sorting it out.