Search code examples
containerspodman

"Connection reset" problem when accessing Podman container


As the Podman (very) beginner that I am, I followed the instructions on the official Podman Getting Started page to pull and run a container of my choice:

someone@something:~$ podman pull docker.io/kizaing/kavita
[...]
someone@something:~$ podman run -dt -p 8080:80/tcp docker.io/kizaing/kavita

I'm not just running commands (completely) blindly. I read about what each flag does in the help dialogues that podman <subcommand> --help provides. In other words, I half-know what I'm doing. Maybe quarter-know.

When trying to access the container via cURL:

someone@something:~$ curl localhost:8080
curl: (56) Recv failure: Connection reset by peer

Firefox:

The connection was reset
~~~~~~~~~~~~~~~~~~~~~~~~
The connection to the server was reset while the page was loading.

* The site could be temporarily unavailable or too busy. Try again in a few moments.
* If you are unable to load any pages, check your computer’s network connection.
* If your computer or network is protected by a firewall or proxy, make sure that Firefox Developer Edition is permitted to access the Web.

I've reloaded the page in Firefox a few times, restarted the Kavita container a few times, tried to play around with the options in my Podman command, but still run into this same issue over and over again.

It's most likely impossible for someone here on SE to just magically guess what is causing my problem, but I'm at least looking for suggestions on why this may be happening, and potential solutions if you think you might have a clue.

Again, I'm quite new to all this, and have never received any formal training in anything computer-related.

Running Debian GNU/Linux 11 (bullseye) x86_64 on top of a 5.10.0-21-amd64 kernel.

Not running a VPN or a proxy when testing.

Edit:

Podman can use port 8080 no problem:

someone@something:~$ sudo ss -lnp | grep 8080
tcp   LISTEN 0      4096                                                                   *:8080                   *:*     users:(("exe",pid=35007,fd=12))  

Besides, httpd runs fine using port 8080, so that confirms once more that Podman has access to the port. In other words, the problem is specific to my Kavita container. (I'm stopping httpd before testing Kavita on that same port, to avoid conflict.)

It was suggested in an answer below to see whether "the webserver is in the container," using podman logs <container-name>. I'm not entirely sure what to look for in that log file, however, so here it is:

someone@something:~$ podman logs quizzical_chaum 
[12:28:37 INF] Generating JWT TokenKey for encrypting user sessions...
[Kavita] [2023-04-01 12:28:39.419 +00:00  1] [Information] API.Program Performing backup as migrations are needed. Backup will be kavita.db in temp folder
[Kavita] [2023-04-01 12:28:39.864 +00:00  1] [Error] Microsoft.EntityFrameworkCore.Database.Command Failed executing DbCommand (48ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
SELECT EXISTS (
    SELECT 1
    FROM "ServerSetting" AS "s")
[Kavita] [2023-04-01 12:28:39.904 +00:00  1] [Error] Microsoft.EntityFrameworkCore.Query An exception occurred while iterating over the results of a query for context type 'API.Data.DataContext'.
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: ServerSetting'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: ServerSetting'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
[Kavita] [2023-04-01 12:28:39.914 +00:00  1] [Information] API.Program Database backed up to /kavita/config/temp/migration/vUnknown
[Kavita] [2023-04-01 12:28:39.935 +00:00  1] [Fatal] API.Program Running MigrateSeriesRelationsExport migration - Please be patient, this may take some time. This is not an error
[Kavita] [2023-04-01 12:28:39.935 +00:00  1] [Fatal] API.Program Running MigrateSeriesRelationsExport migration - complete. Nothing to do
[Kavita] [2023-04-01 12:28:57.271 +00:00  1] [Information] API.Services.TaskScheduler Scheduling reoccurring tasks
[Kavita] [2023-04-01 12:28:57.282 +00:00  1] [Debug] API.Services.TaskScheduler Scheduling Scan Library Task for daily
[Kavita] [2023-04-01 12:28:57.489 +00:00  1] [Debug] API.Services.TaskScheduler Scheduling Backup Task for daily
[Kavita] [2023-04-01 12:28:57.496 +00:00  1] [Information] API.Services.TaskScheduler Scheduling Auto-Update tasks
[Kavita] [2023-04-01 12:28:57.501 +00:00  1] [Debug] API.Services.TaskScheduler Scheduling stat collection daily
[Kavita] [2023-04-01 12:28:57.681 +00:00  6] [Information] API.Program Running Migrations
[Kavita] [2023-04-01 12:28:57.800 +00:00  6] [Fatal] API.Program Running MigrateChangeRestrictionRoles migration
[Kavita] [2023-04-01 12:28:57.801 +00:00  6] [Information] API.Program MigrateChangeRestrictionRoles migration complete
[Kavita] [2023-04-01 12:28:57.815 +00:00  6] [Fatal] API.Program Running MigrateSeriesRelationsImport migration - Please be patient, this may take some time. This is not an error
[Kavita] [2023-04-01 12:28:57.816 +00:00  6] [Fatal] API.Program Running MigrateSeriesRelationsImport migration - complete. Nothing to do
[Kavita] [2023-04-01 12:28:57.820 +00:00  6] [Fatal] API.Program Running MigrateUserProgressLibraryId migration - Please be patient, this may take some time. This is not an error
[Kavita] [2023-04-01 12:28:57.826 +00:00  6] [Warning] Microsoft.EntityFrameworkCore.Query The query uses the 'First'/'FirstOrDefault' operator without 'OrderBy' and filter operators. This may lead to unpredictable results.
[Kavita] [2023-04-01 12:28:57.833 +00:00  6] [Fatal] API.Program Running MigrateUserProgressLibraryId migration - complete. Nothing to do
[Kavita] [2023-04-01 12:28:57.905 +00:00  6] [Information] API.Program Running Migrations - done
[Kavita] [2023-04-01 12:28:58.228 +00:00  1] [Information] Microsoft.Hosting.Lifetime Now listening on: http://0.0.0.0:5000
[Kavita] [2023-04-01 12:28:58.229 +00:00  1] [Information] Microsoft.Hosting.Lifetime Now listening on: http://[::]:5000
Kavita - v0.7.1.4
[Kavita] [2023-04-01 12:28:58.231 +00:00  1] [Information] Microsoft.Hosting.Lifetime Application started. Press Ctrl+C to shut down.
[Kavita] [2023-04-01 12:28:58.232 +00:00  1] [Information] Microsoft.Hosting.Lifetime Hosting environment: Production
[Kavita] [2023-04-01 12:28:58.232 +00:00  1] [Information] Microsoft.Hosting.Lifetime Content root path: /kavita
someone@something:~$

Also, if you're interested in knowing whether the web server is running within the container, perhaps the output from Podman's top subcommand might be of interest:

someone@something:~$ podman top <container-name>
USER   PID   PPID   %CPU    ELAPSED            TTY     TIME   COMMAND
root   1     0      0.000   29m47.804865961s   pts/0   0s     /bin/bash /entrypoint.sh 
root   3     1      0.671   29m47.805063227s   pts/0   12s    ./Kavita
someone@something:~$

As far as I know, that means "no, there is no webserver running," but perhaps I am mistaken.


Solution

  • If you half-know what you are doing that makes you better prepared than 90% of people asking questions here :-)

    Your basic example works fine for me.

    $ podman run -dt -p 8888:80/tcp docker.io/library/httpd
    Trying to pull docker.io/library/httpd:latest...
    Getting image source signatures
    ...does its thing building up image layers...
    4a12f492d4e153c76987f9fc8def761ac7c9d758011ba8859ec6ab9937668b07
    
    $ podman ps -a
    CONTAINER ID  IMAGE                            COMMAND           CREATED        STATUS            PORTS                    NAMES
    4a12f492d4e1  docker.io/library/httpd:latest   httpd-foreground  4 seconds ago  Up 4 seconds ago  0.0.0.0:8888->80/tcp     pedantic_nightingale
    
    $ curl http://localhost:8888/
    <html><body><h1>It works!</h1></body></html>
    

    I used port 8888 because I have something running on port 8080 already.

    So - there are three things to check if yours is not working.

    1. Is the container actually running (check with podman ps -a)?
    2. Is it able to use the port? (sudo ss -lnp | grep 8080 will show what is listening on that port)
    3. Is the webserver in the container (podman logs <container-name>)

    Check those three items and see if any of those give you a clue.

    (If you are running podman v3.0 on Debian, be aware that a lot of the online docs are for later versions. The basic stuff all works the same, but networking and docker-sockets etc have changed)