Table of Contents
ToggleIntroduction
Pixiv is one of the most popular platforms for artists, illustrations, and digital artwork. Many users rely on gallery-dl to download Pixiv images, manage collections, or maintain a personal archive. However, one of the most frequent challenges is Pixiv login or token errors. These errors prevent gallery-dl from accessing restricted content, including private artworks, members-only pages, and R-rated content.
These issues often occur because Pixiv uses authentication tokens instead of a simple login system. Tokens expire or change when Pixiv updates its API, forcing users to refresh their credentials. Without proper authentication, gallery-dl cannot download Pixiv images, even though it works fine for public content.
In this guide, we will explore the causes of Pixiv login/token errors in gallery-dl and provide step-by-step solutions. You’ll also learn best practices for maintaining uninterrupted downloads and automating the process safely.
What is Pixiv authentication in gallery-dl?
Pixiv requires users to be logged in to access some content. gallery-dl supports authentication using:
- Username and password – only works for basic login and often fails due to Pixiv’s two-factor or token system.
- Refresh tokens/Access tokens – recommended method. Tokens allow gallery-dl to authenticate without exposing your password.
- Cookies – exported from your browser to provide authenticated sessions.
Pixiv periodically rotates its authentication tokens. If your token expires or becomes invalid, gallery-dl will fail to download Pixiv images, often returning errors like:
- Login required
- PixivError: Invalid token
- Authentication failed
- Cannot retrieve media

Common Causes of Pixiv Login/Token Errors
- Expired Tokens – Tokens must be refreshed periodically.
- Incorrect Credentials – Username, password, or cookies may be wrong.
- Two-Factor Authentication (2FA) – Pixiv may block direct login attempts without 2FA.
- Outdated gallery-dl Version – Changes in Pixiv’s API may require the latest gallery-dl update.
- Rate Limiting – Pixiv may temporarily block requests if too many downloads occur in a short time.
- Incorrect Configuration – Errors in the config.json file for the Pixiv extractor can cause failures.
Fix #1: Update gallery-dl
The first step in fixing Pixiv login/token errors is to ensure that gallery-dl is up to date. Developers frequently release updates to accommodate changes to the Pixiv API.
pip install --upgrade gallery-dl
Or, if using a package manager:
Homebrew (macOS):
brew upgrade gallery-dl
APT (Ubuntu/Debian):
sudo apt updatesudo apt upgrade gallery-dl
After updating, try downloading a protected Pixiv artwork.
Fix #2: Using Refresh Tokens for Pixiv
Using refresh tokens is the recommended method for authentication.
Step 1: Obtain a Refresh Token
- Go to Pixiv and log in with your account in a web browser.
- Open browser developer tools (F12) → Network tab.
- Click any API request to https://app-api.pixiv.net/ and locate the
refresh_tokenparameters. - Copy the refresh_token value.
Step 2: Configure gallery-dl
Edit your gallery-dl configuration file (config.json) located at:
- Linux/macOS: ~/.config/gallery-dl/config.json
- Windows: %APPDATA%\gallery-dl\config.json
Add your Pixiv token:
{
"extractor": {
"pixiv": {
"refresh_token": "YOUR_REFRESH_TOKEN_HERE"
}
}
}
Save the file and test:
gallery-dl https://www.pixiv.net/en/artworks/123456
If the token is valid, gallery-dl will successfully download the artwork.
Fix #3: Using Cookies for Authentication
Cookies provide an alternative authentication method, especially if refresh tokens fail.
Step 1: Export Pixiv Cookies
Use browser extensions such as:
- Get cookies.txt
- Cookie-Editor
Export the cookies to a file named
pixiv_cookies.txt
Step 2: Use Cookies with gallery-dl
Run the download command with the cookies:
gallery-dl --cookies pixiv_cookies.txt https://www.pixiv.net/en/artworks/123456
This method allows gallery-dl to access private artworks and members-only content.
Fix #4: Enable Two-Factor Authentication Support
If your Pixiv account uses 2FA, direct login with username/password may fail.
To resolve this:
- Use refresh tokens or cookies, as mentioned above.
- Avoid using plain username/password login in gallery-dl.
This ensures Pixiv authentication works without requiring 2FA prompts.
Fix #5: Check for Outdated Configuration
Old or incorrect settings in config.json may cause token errors.
- Ensure Pixiv extractor settings are correct.
- Remove deprecated keys such as “username” or “password” when using refresh tokens.
- Test with a minimal configuration:
{
"extractor": {
"pixiv": {
"refresh_token": "YOUR_REFRESH_TOKEN_HERE"
}
}
}
This eliminates potential conflicts.
Fix #6: Handle Rate Limits
Pixiv may temporarily block your account if too many downloads occur within a short period.
- Reduce simultaneous downloads using –wait:
gallery-dl --wait 5 https://www.pixiv.net/en/artworks/123456
- Avoid automated bulk downloads that exceed Pixiv’s limits.
- If blocked, wait 24 hours before retrying.
Fix #7: Test Download with a Public Artwork
Before attempting members-only content, test with a public Pixiv artwork:
gallery-dl https://www.pixiv.net/en/artworks/654321
If this works, your setup is correct, and the issue likely occurs only with restricted content. Using refresh tokens or cookies should solve the problem.
Best Practices for Avoiding Pixiv Login/Token Errors
- Keep gallery-dl updated regularly.
- Always use refresh tokens or cookies instead of plain passwords.
- Monitor Pixiv API changes via the gallery-dl GitHub repository.
- Avoid exceeding download limits to prevent account restrictions.
- Backup your configuration (config.json) and tokens.
Following these practices ensures uninterrupted downloads and a smooth experience with the Pixiv image downloader.
Testing Your Fix
After applying one of the above solutions:
gallery-dl https://www.pixiv.net/en/artworks/123456
If the artwork downloads successfully, your Pixiv login/token issue is resolved. You can then continue using gallery-dl to download:
- Single artworks
- Multiple images in a gallery
- Members-only content
- Manga pages
Many users also combine it with bulk downloads from Reddit, Twitter/X media, and Tumblr media, leveraging gallery-dl as a complete multi-platform media downloader.
Conclusion
Pixiv login/token errors in gallery-dl are a common issue due to the platform’s authentication system. The most effective solutions involve:
- Updating gallery-dl to the latest version.
- Using refresh tokens for authentication.
- Exporting Pixiv cookies when necessary.
- Avoid plain username/password login, especially with 2FA accounts.
- Monitoring rate limits and respecting API usage policies.
By following these steps, you can restore gallery-dl functionality and continue downloading Pixiv images, including restricted and members-only content.
FAQs
Q1: Why does gallery-dl fail to login to Pixiv?
A: gallery-dl often fails to login to Pixiv due to expired or invalid authentication tokens. Using a refresh token or exporting Pixiv cookies ensures successful login and allows gallery-dl to download restricted content.
Q2: How do I get a Pixiv refresh token for gallery-dl?
A: Log in to Pixiv via a web browser, open developer tools, and locate the refresh_token in API requests to app-api.pixiv.net. Add this token to your gallery-dl config.json to authenticate your downloads.
Q3: Can I use cookies instead of tokens for Pixiv login?
A: Yes. You can export Pixiv cookies from your browser using a cookie extension and use the –cookies option in gallery-dl. This lets the tool access private and members-only Pixiv content.
Q4: Does two-factor authentication affect gallery-dl downloads?
A: Yes. Pixiv accounts with 2FA cannot use direct username/password login in gallery-dl. Use refresh tokens or cookies to safely bypass 2FA when downloading images.
Q5: How do I update gallery-dl to fix Pixiv login errors?
A: Run pip install –upgrade gallery-dl to update the tool. The latest version ensures compatibility with changes to the Pixiv API and resolves most login or token issues.
Latest Post: